How can I change color of a section header in UITableView?
EDIT: The answer provided by DJ-S should be considered for iOS 6 and above. The accepted
Although func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)
will work as well, you can acheive this without implementing another delegate method.
in you func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
method, you can use view.contentView.backgroundColor = UIColor.white
instead of view.backgroundView?.backgroundColor = UIColor.white
which is not working. (I know that backgroundView
is optional, but even when it is there, this is not woking without implementing willDisplayHeaderView