Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing UITableViewCell background

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:

enter image description here

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

like image 467
aherlambang Avatar asked Apr 13 '11 23:04

aherlambang


People also ask

How do I change the background color of a selected cell in Swift?

Swift 3, 4, 5 select cell background colour Next connect your cell's selectedBackgroundView Outlet to this view. You can even connect multiple cells' outlets to this one view. Show activity on this post. For a solution that works (properly) with UIAppearance for iOS 7 (and higher?)

How do I remove background color in excel?

To remove any background colors, patterns, or fill effects from cells, just select the cells. Then click Home > arrow next to Fill Color, and then pick No Fill.


1 Answers

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];
}
like image 109
conmulligan Avatar answered Sep 29 '22 09:09

conmulligan