Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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];
like image 994
Zhen Avatar asked Aug 10 '11 16:08

Zhen


2 Answers

UIImageView

UIImageView with a chevron image on the right-hand side. Preferably in the storyboard, but it can easily be managed in code by attaching it to the content view.

like image 192
Cameron Lowell Palmer Avatar answered Nov 15 '22 18:11

Cameron Lowell Palmer


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"];
like image 42
Noah Witherspoon Avatar answered Nov 15 '22 17:11

Noah Witherspoon