Paul Cezanne
Paul Cezanne

Reputation: 8741

What is the default background color of a UITableViewStyleGrouped styled UITableView Cell

I need to set the backgound color of a cell in my UITableView. That works fine. Then, later, I want to restore it to the original color. Now, under iOS4 that color is white, under iOS 5 that color is #f7f7f7 (See Different cell bg color depending on iOS version (4.0 to 5.0) )

Now, I can always ask the cell in viewDidLoad what's its background color is, but that seems like a hack. I'd love it if there was a call already in place by Apple. Since it is iOS version dependent, it won't be a static UIColor method.

So, is there a cleaner way of getting this color or do I just have to ask when the dialog first comes up?

Interesting, I can't get the background color programatically! If I do this:

backgroundCellColor = usernameCell.backgroundColor; 
NSLog(@"*** backgroundcolor is: %@",backgroundCellColor);

then when I look at my Console I see this:

2011-12-06 15:11:08.686 Ferret[47035:f803] *** backgroundcolor is: (null)

Thanks!

Upvotes: 2

Views: 2023

Answers (2)

Vincent Bernier
Vincent Bernier

Reputation: 8664

Have you try to set the cell back to this value of (null). Just to be certain, cache the variable and feed it back that value.
What does it do?

Upvotes: 0

David Dunham
David Dunham

Reputation: 8329

I think asking for the original is NOT a hack. For one thing, it allows Apple to change the look as they see fit. It also allows YOU to customize things in a nib file.

Upvotes: 1

Related Questions