views:

205

answers:

1

I am having a problem with the background color of my table view. In Interface Builder, I have the background color set, and it shows correctly there. When I run my application, however, there is no background color there (it is the default white).

I have discovered that I can set the background color in the table view delegate file:

tableView.backgroundColor = [UIColor lightTextColor];

The problem with that is I want to use one of the colors out of the Crayon palette.

So, is there some reason that the background color isn't showing up in the first place? Or, if I have to override it like my code example above, how can I set it to one of the Crayon colors?

Any help is much appreciated!


I JUST realized that IB will tell you the RGB values of any colors, you just have to switch the slider from Grey Sliders to RGB Slider when setting the colors. I didn't even realize that was an option. So, the lesson of a newbie has been learned!


Alright, in my case I wanted to color my table "Mercury." To do this, I used IB to tell me what the RGB value of that color was (change the slider from Gray to RGB). The RGB values for Mercury were 230, 230, 230. I then modified Jason's code and placed it the numberOfRowsInSection method of my tableView delegate.

tableView.backgroundColor = [UIColor colorWithRed:230.0f/255.0f green:230.0f/255.0f blue:230.0f/255.0f alpha:1.0f];

Things to note: Don't forget to include your f's! Otherwise you'll wind up with all zeros -- aka, black.

This worked like a charm, thanks!

+1  A: 

try here

or here

or even here....

The reason might simply be that your cells are coloured white, not transparent so you cant see the colour below.

Aran Mulholland
I colored the cells transparent, and that didn't change anything. Thanks for the links though, those look very promising! I will look into it further tonight or tomorrow.
IcyBlueRose
which view did you set as transparent? The contentView or the backgroundView?
Aran Mulholland
As far as I recall, the backgroundView. I would have to look it up though. Still haven't gotten a chance to look into the links yet, I shall do that today.
IcyBlueRose
I wound up using the other solution, but I just wanted you to know that I really appreciated the help, and the links. Thanks!
IcyBlueRose