我发现了类似的问题,但没有人帮助我。 我需要设置标题的背景颜色在我的表为白色,它是灰色的,现在(与表格的背景颜色)。如何在TableView中为标题设置背景颜色?
这里是我的tableView
功能:
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)
{
let header = view as! UITableViewHeaderFooterView
header.backgroundColor = UIColor.white
header.textLabel?.font = UIFont(name: "Futura", size: 13)!
header.textLabel?.textColor = UIColor.blue
}
func tableView(tableView: UITableView, ViewForHeaderInSection section: Int) -> UIView? {
tableView.backgroundColor = UIColor.white
return tableView
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?
{
return titles[section]
}
我设置背景颜色为白色,但没有任何变化。 UITableView中的
我代替我的'viewForHeaderInSection'与你(我的输入错误,顺便说一句),但它并没有帮助。 – Jamil
你应该设置的UITableView – iParesh
的heightForHeaderInSection添加了这个功能,还是没有效果 – Jamil