Reputation: 14418
I know this might have been asked thousands time, I tried changing the background for my UITablewViewCell via the following:
cell.contentView.backgroundColor = [UIColor colorWithRed:0 green:0.188235 blue:0.313725 alpha:1];
cell.textLabel.backgroundColor = [UIColor colorWithRed:0 green:0.188235 blue:0.313725 alpha:1];
and all I have now is:
How do I set that accessory view background view color as well?
UPDATE: I have a section header on top in which it has a white background
Upvotes: 6
Views: 7004
Reputation: 169
//in willDisplayCell
if (indexPath.section > 0) {
cell.backgroundColor = [UIColor blueColor];
}
Upvotes: -3
Reputation: 2820
You're over-complicating it a bit. You can just change the tableview's background color which does exactly what you want. This way, you don't have to set the color for EVERY cell. :)
self.tableView.backgroundColor = [UIColor greenColor];
Upvotes: 0
Reputation: 7148
Put this in your UITableViewDelegate
:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor colorWithRed:0 green:0.188235 blue:0.313725 alpha:1];
}
Upvotes: 13