Take the 2-minute tour ×

I am trying to set the cell background of my UITableViewCells but I am struggling with the background color of the UIAccessoryView. It does not change.

Can anyone help me make the background color of the UIAccessoryView transparent (or actually any other color)?

This is my code

cell.textLabel.backgroundColor = [UIColor clearColor];
cell.accessoryView.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

if(indexPath.row % 2) {
     cell.contentView.backgroundColor = [UIColor clearColor];
else {
    cell.contentView.backgroundColor = [UIColor redColor];

Here is an image illustrating the issue

UIAccessoryView does not change background color.

share|improve this question

2 Answers 2

up vote 37 down vote accepted

You'll need to set the backgroundView property of the UITableViewCell. For example:

UIView* myBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
myBackgroundView.backgroundColor = [UIColor redColor];
myCell.backgroundView = myBackgroundView;

If you want something more fancy, like a red gradient background, you would implement a subclass of UIView that draws a gradient in drawRect:, and use it as the backgroundView.

You can also set the selectedBackgroundView property if you want a custom look for a selected table cell.

share|improve this answer
Awesome! That works and is so much easier! Good idea with gradient and a selectedBackgroundView Thank you very much! –  simonbs Mar 19 '11 at 13:24
Thanks a lot... Got stuck for a long time here and your answer was the first one to solve it. :) –  Thomas Johannesmeyer Jun 15 '13 at 1:08
+1 for nice answer, Thanks a lot. –  Edward Feb 24 at 6:38

In function


Use following code

cell.contentView.superview.backgroundColor = [UIColor redColor];

reference for more details

share|improve this answer
works well, thanks for single line approach :-) –  PetrV Jan 8 '13 at 15:01

Your Answer


