mpatric.com

If, like me, you have iOS projects that use custom table cells in table views, you may have noticed that when rebuilding the projects for iOS7, table cells are always rendered with a white background, which means if your custom table cells have their own background you may not see it. The solution to this problem can be found in the 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.

To change the background of cells to transparent to allow the background of the custom table cell to show, implement a method such as the following in your UITableViewController subclass:

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

Posted Sat 02 Nov 2013 by Michael Patricios

Tags: Development, iOS, Objective-C

Post a comment