2
我将TableView从Plain更改为Grouped,以便页眉/页脚不会浮动在表上并保持锚定在表的顶部和底部。这很简单,但现在我设置的字体样式格式不起作用。奇怪的是,页眉/页脚的所有其他格式似乎都在工作。任何关于发生了什么事以及我失踪的想法都会很感激!下面分组表中的TableView页眉/页脚字体(Swift)
代码:
// Setup format of the header
func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let title = UILabel()
title.font = UIFont(name: "Avenir Book", size: 12)
title.textColor = UIColor.whiteColor()
let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
header.contentView.backgroundColor = UIColor(red: 30/255, green: 30/255, blue: 50/255, alpha: 1)
header.textLabel!.font = title.font
header.textLabel?.textColor = title.textColor
header.textLabel?.numberOfLines = 0
header.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
header.textLabel?.textAlignment = NSTextAlignment.Center
}
在一个普通的表上述所有的伟大工程,是这样的:
然而,当我更改为分组表的所有格式的似乎显示除了字体样式这个这个:
我对所有CAPS来自哪里感到困惑。
我试图从this question/answer实施解决方案,但无法让它工作。感谢您的想法!
啊有道理!非常感谢!我选择将字符串添加到titleForHeaderInSection中以保留句子大小写。 – Ben