2

I want to change the background colour of a cell inside UITableView from default white to something else. If the style is UITableViewStylePlain then its very easy and we can just do:

tableView.backgroundColor = [UIColor blackColor];

However, the same is not happening inside UITableViewStyleGrouped.

Can anyone kindly help me out ? Thanks.

Roy Sharon
  • 3,488
  • 4
  • 24
  • 34
Ahsan
  • 2,964
  • 11
  • 53
  • 96
  • possible duplicate of [Change iPhone tableview (style grouped) background color while preserving texture](http://stackoverflow.com/questions/933808/change-iphone-tableview-style-grouped-background-color-while-preserving-texture) – Jeremy W. Sherman Jun 08 '11 at 17:33
  • Have a look at this post! [#933992](http://stackoverflow.com/questions/933808/change-iphone-tableview-style-grouped-background-color-while-preserving-texture/933992#933992) – Raphael Jun 08 '11 at 12:34

3 Answers3

10

When using UITableViewStylePlain, tableView do not have a backgroundView, but when it comes to UITableViewStyleGrouped, we can see tableView's backgroundView is not nil. So the solution is simple, set this backgroundView to nil, and it's done.

tableView.backgroundColor = [UIColor blackColor];
tableView.backgroundView = nil;

And you can see the blackColor background now!

Senry
  • 260
  • 4
  • 15
3
[cell setBackgroundColor:[UIColor blackcolor]];

try this and you can change cell background color.

2

What we can do is use an UIImageView that will span the whole of the cell. Couldn't find a better way to do this. Thanks.

Ahsan
  • 2,964
  • 11
  • 53
  • 96