我想要在表格视图控制器中更改某个部分标题的字体类型和字体大小。
我的代码:
func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let header = view as! UITableViewHeaderFooterView
header.textLabel.textColor = UIColor.blackColor()
header.textLabel.font = UIFont(name: "Futura", size: 38)!
}
但是这样做行不通。有什么想法吗?
viewForHeaderInSection
方法中尝试上述代码。并为标题文本取一个标签var title = UILabel() title.font = UIFont(name: "Futura", size: 38)! title.textColor = UIColor.lightGrayColor()
然后将其添加到头部视图中header.addSubview(title)
。 - iRiziya