Change color of the area below the last section of a uitableview

144 Views Asked by At

I have a UITableView. I figured out how to change the background color for the section headers. However, it also changes the bottom area that contains "no section/rows" to the same color. I don't want this.

Is there anyway I can set the color of that area to be a different color than the section headers?

See example picture for more information.Area in blue at the bottom is the part that I want to be a different color

Any help is greatly appreciated. I've done research but I haven't found anything yet.

1

There are 1 best solutions below

0
On

Basically, what I had to do was:

In Interface Builder, change the color of the view to what you want displayed at the bottom.

I used the same color that I had set for my table cell rows.

For the section headers:

In the willDisplayHeaderView method, do:

UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
header.contentView.backgroundColor = [UIColor blueColor];    

Please note: If you get a white/gray line above the section header - this deals with the footer. So, in viewDidLoad method, set the table footer height to 0:

self.tableView.sectionFooterHeight = 0.0;