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