更改 STATIC table 视图的颜色 header 不起作用

Change Color of STATIC table view header does not work

大家好,我有个小问题。 我在故事板中创建了一个带有静态单元格的 table 视图。现在我将更改 header 部分的颜色,但我不知道为什么这不起作用。对于正常的 table 视图,我使用此代码:

    override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let footer = UIView()
    footer.backgroundColor = UIColor.red
    return footer
}

我在我的 UITableViewController 文件中写道,它链接到故事板中的 Tableview 控制器,但 headers 保持灰色。当我使用没有静态单元格的相同代码时,header 的颜色变为红色。

希望你能帮帮我。

PS:抱歉我的英语不好。

使用 viewForHeaderInSection 来更改 'header' 属性而不是 viewForFooterInSection。