In my code I use below code to set the section header title of the tableview. And it works well.
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int)
-> String? {
//return self.adHeaders[section]
return self.headers[section]
}
I want to customize the background color of the header, so I insert below code before the above code.
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView()
headerView.backgroundColor = UIColor(red: 232/255.0, green: 237/255.0, blue: 242/255.0, alpha: 1.0)
return headerView
}
As a result, the background color changes, while the title text lost.