Reputation: 11193
i'm trying to change the headerView Color in a Grouped
tabledView. However there seem to be a weird behaviour in the second header. Where it doesnt fill the comlete header? How come this?
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
}
Upvotes: 0
Views: 525
Reputation: 6352
Grouped tableviews have table section footers. You are seeing the grey of the footer for section. In the - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
method return 0 or CGFLOAT_MIN
to hide the footer. I think there is a situation where 0 doesn't work and you have to do CGFLOAT_MIN
but try both if 0 doesn't work.
Below is swift example
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return CGFLOAT_MIN; }
Upvotes: 2
Reputation: 24466
I think you're misinterpreting what is likely the footer of the first section as the top of the header of the second section. If you look closely, you'll see that your red areas are in fact the same height. Two things to check. First, see what your table footer height is set to--might be non zero. You can change this in interface builder. Second, try changing your table view to regular rather than grouped and see if that changes anything.
Upvotes: 0