UITableViewCell show white background and cannot be modified on iOS7

As Apple DOC said (UITableViewCell Class Reference):

In iOS 7, cells have a white background by default; in earlier versions of iOS, cells inherit the background color of the enclosing table view. If you want to change the background color of a cell, do so in the tableView:willDisplayCell:forRowAtIndexPath: method of your table view delegate.

So for my case that to show cells with transparent background, just need to implement the delegate method in the table view controller like below:

- (void)tableView:(UITableView *)tableView
  willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
  [cell setBackgroundColor:[UIColor clearColor]];
}

Just Note: As @null said, “…there seems to be a bug in interface builder…”, I’m not totally sure whether it does have the bug, but seems so cause his comment got several up votes. So there might something wrong if you use IB. 🙂

Leave a Comment