Search code examples
objective-ciosuitableviewbackground-color

Objective C: How to add color to entire cell (with a disclosure indicator)


I am trying to add background color to my cell but was not able to color the portion with the disclosure indicator (see screenshot below)

enter image description here

What can I do to color the entire cell? My implementation as follows.

cell.contentView.backgroundColor = [UIColor colorWithHexString:@"#FFFFCC"];

//Clear colors for labels
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];

Solution

  • UITableViewCell subclasses UIView; you can set its background color just as you can any other view’s. Cells in a “grouped”-style table view require some more work there, but it doesn’t look like you’re using that, so:

    cell.backgroundColor = [UIColor colorWithHexString:@"#FFFFCC"];