I\'m trying to change the background color of UITableViewHeaderFooterView. Although the view is appearing, the background color remains the default color. I\'m getting a log
On iOS9 headerView.backgroundView.backgroundColor
worked for me:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
TableViewHeader *headerView = (TableViewHeader *)[super tableView:tableView viewForHeaderInSection:section];
headerView.backgroundView.backgroundColor = [UIColor redColor];
}
On iOS8 I was using headerView.contentView.backgroundColor
without problems, but now with iOS 9, I was getting a weird issue that made the background color not fill the whole space of the cell. So I tried just headerView.backgroundColor
and I got the same error from the OP.
Setting the background color on UITableViewHeaderFooterView has been deprecated. Please use contentView.backgroundColor instead.
So now everything works great and without warnings by using headerView.backgroundView.backgroundColor