I assume you are trying this in cellForRowAtIndexPath.
According to the UITableViewCell class reference:
Note: If you want to change the
background color of a cell (by setting
the background color of a cell via the
backgroundColor property declared by
UIView) you must do it in the
tableView:willDisplayCell:forRowAtIndexPath:
method of the delegate and not in
tableView:cellForRowAtIndexPath: of
the data source.
So do this:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor redColor]; //must do here in willDisplayCell
cell.textLabel.backgroundColor = [UIColor redColor]; //must do here in willDisplayCell
cell.textLabel.textColor = [UIColor yellowColor]; //can do here OR in cellForRowAtIndexPath
}
If you need finer control over the cell display, an easy way is to design it in IB and load it from the nib in cellForRowAtIndexPath. See the "Loading Custom Table-View Cells From Nib Files" section on this page in the Table View Programming Guide.