Update
Apparently, the existing UITableViewCell structure makes it very difficult to change the background color in a cell and works well through all its state changes (editing mode, etc.).
The solution was posted on this SO question , and it has been announced in several forums as "the only solution approved by Apple engineers." It includes a subclass of UITableViewCell and the addition of a custom view for the backgroundView subclass property.
Original mail - this solution does not work fully, but may be useful in some situations
If you already have a UITableViewCell, just change its contentView backgroundColor property.
If you need to create UITableViewCells with a custom background color, the process is a bit longer. First, you need to create a data source for your UITableView - it can be any object that implements the UITableViewDataSource protocol.
In this object, you need to implement the tableView:cellForRowAtIndexPath: method, which returns a UITableViewCell when it is provided with NSIndexPath for the location of the cell inside the table. When you create this cell, you will want to change the backgroundColor property of your contentView .
Remember to set the dataSource UITableView property to a data source object.
For more information, you can read these API docs:
Please note that registration as an Apple developer is required for all three of these links.
source share