UITableView Color Changes in iOS 7

Before iOS 7, the default background color for a UITableView was clearColor, and UITableViewCells by default took on the UITableView’s background color, so there was virtually no work setting up our tables in iOS 6.

When you switch to Xcode 5, your tables will default to the new iOS 7 behavior.  UITableView’s have a white background color by default, so you must change it to clearColor either in Interface Builder or programmatically.

More importantly, UITableViewCell’s no longer pick up the background color of the UITableView and are white by default. Setting the backgroundColor in InterfaceBuilder for a UITableViewCell has no effect (to my surprise I guess this has always been the case).

So, the “correct” way (based on Apple’s documentation in UITableViewCell) to set the UITableViewCell’s backgroundColor is to do it in the UITableViewDelegate willDisplayCell method, as shown here:


- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    cell.backgroundColor = [UIColor clearColor];

Also, be sure your UITableViewCell’s contentView.backgroundColor is also set to clearColor (this can be done in Interface Builder).


I have found though that I can set the backgroundColor when I deque the cells in cellForRowAtIndexPath, but I’m not 100% sure this will work in all cases.



2 thoughts on “UITableView Color Changes in iOS 7

  1. I have tried to change the color of my cell, just like you described, but the cell remains white (or clear for that matter, I cannot really tell).

    Do you have any explanation for this behavior on iOS 7.1 ? Here is my code:

    – (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    cell.contentView.backgroundColor = [UIColor clearColor];
    cell.backgroundColor = [UIColor redColor];

  2. You may want to try doing it in the cellForIndexPath method when you deque the cell. There have definitely been oddities where the willDisplayCell doesn’t get called. You might also try setting the contentView background color to red and see if that shows up.

Leave a Reply

Your email address will not be published. Required fields are marked *