微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

UITableView 中部分标题的颜色

如何解决UITableView 中部分标题的颜色

我正在创建一个表格,我希望所有部分的标题为黑色,部分的页脚为绿色。 页眉/页脚是使用 UITableViewheaderfooterView

创建的
let sectionFooterView: UITableViewheaderfooterView = {
        UITableViewheaderfooterView()
    }()

设置背景颜色的代码

func tableView(_: UITableView,viewForHeaderInSection _: Int) -> UIView? {
    let view = mainView.sectionHeaderView
    view.tintColor = .black
    return view
}

func tableView(_: UITableView,heightForHeaderInSection _: Int) -> CGFloat {
    UITableView.automaticDimension
}

func tableView(_: UITableView,viewForFooterInSection _: Int) -> UIView? {
    let view = mainView.sectionFooterView
    view.tintColor = .green
    return view
}

func tableView(_: UITableView,heightForFooterInSection _: Int) -> CGFloat {
    UITableView.automaticDimension
}

我只对表格中间某处的页眉/页脚进行了着色,但大多数页眉/页脚仍然是清晰的颜色。有什么要改变的?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。