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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With