Why doesn\'t UITableViewCell background color work (set in interface builder)?
I note from some searching that the follow code set in your custom subclass of UITable
Y not, use setBackgroundColor
self.table.separatorColor=[UIColor whiteColor];
[table setBackgroundColor:[UIColor colorWithRed:.8 green:.8 blue:1 alpha:1]];
I did get this issue also. In IB you get the ability to change the background color of the cell when choosing cell. This is NOT correct. You should go to the document outline on the left of the storyboard and choose the content view inside the cell. Change the background of the content view. You should now get correct cell color.
You should always provide changes for cells in tableView:willDisplayCell:forRowAtIndexPath:
instead of the tableView:cellForRowAtIndexPath:
method, as per Apple Documentation.
This Works !!
You can partially do this in Interface Builder (probably added to Xcode recently):
Still don't see a way to set the accessory background though.
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
UIView *view = [[UIView alloc] init];
[view setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:view];}
We need to change the color in this method.
Make sure before defining a cell color your backgroundView
is null
cell.backgroundView = nil;
cell.backgroundColor = [UIColor redColor];