If you just need to change the color or font on the header, use tableView: willDisplayHeaderView: forSection:
. Here is an example in swift:
Swift v5:
override public func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
if let view = view as? UITableViewHeaderFooterView {
view.backgroundView?.backgroundColor = UIColor.blue
view.textLabel?.backgroundColor = UIColor.clear
view.textLabel?.textColor = UIColor.white
}
}
Original:
override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
if let view = view as? UITableViewHeaderFooterView {
view.backgroundView?.backgroundColor = ThemeBlue
view.textLabel.backgroundColor = UIColor.clearColor()
view.textLabel.textColor = UIColor.whiteColor()
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…