ios - 更改标题 View 的背景颜色

标签 ios objective-c swift uitableview

我正在尝试更改 Grouped tabledView 中的 headerView 颜色。但是,第二个 header 中似乎有一种奇怪的行为。哪里没有填写完整的标题?这是怎么来的?

override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    var headerView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, 44))
    headerView.backgroundColor = UIColor.redColor()





    return headerView
}

override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 44
}

enter image description here

最佳答案

分组的表格 View 有表格部分的页脚。您看到部分页脚的灰色。在 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 方法中返回 0 或 CGFLOAT_MIN 以隐藏页脚。我认为存在 0 不起作用的情况,您必须执行 CGFLOAT_MIN 但如果 0 不起作用,请尝试两者。

下面是快速示例 override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return CGFLOAT_MIN; }

关于ios - 更改标题 View 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31974487/

相关文章:

php - 使用 """从 php 服务器获取 json 数据

ios - Swift:在协议(protocol)一致性中覆盖协议(protocol)扩展的关联类型

ios - 是否 managedObjectContext.object(with :) always refetch data if another (private) managedObjectContext changed and saved it?

ios - 在 Swift 的数组中查找 SKSpriteNode 的索引

iphone - AVAssetReader 读取视频样本的基本问题

iphone - 如何动态设置 ScrollView 内容大小?

iphone - 使用父/子上下文时批量大小不起作用

ios - 在文本矩阵中使用多个 CGAffineTransform

iphone - 将 API 端点作为常量进行管理

ios - 重命名文件(如果文件已存在)