18

How can we change the background color of tableview (style grouped) while still preserving texture of thin columns/lines effect that we can see when it has the default blue color.If i try to change background color using backgroundcolor property i get a plain view without any texture.

thanks

4 Answers4

75
tableview.backgroundView = nil;
tableview.backgroundColor = [UIColor clearColor];

This may help you in solving your problem

Aswathy Bose
  • 4,279
  • 4
  • 32
  • 44
  • Worked for me too, but I set the backGroundColor to the color I wanted instead of making it `clearColor` – Ali Oct 02 '12 at 20:58
  • @Ali Yes you can set the background color as per your requirements.tableview.backgroundView = nil will help you to remove the plain view from the grouped table. – Aswathy Bose Oct 03 '12 at 03:29
13

Firstly, you could try searching on Stack overflow for your exact question. Here's two:

If that doesn't help, try to make the background colour of the table view transparent [UIColor clearColor] and put another view behind your UITableview containing the colout/texture/image you need.

Community
  • 1
  • 1
Rog
  • 17,070
  • 9
  • 50
  • 73
0

Create the property of tableView:

@property (nonatomic, strong) IBOutlet UITableView *tableView;

Then synthesize it:

@synthesize tableView = _tableView;

In implementation create method:

- (UITableView *) tableView {
  [_tableView setBackgroundColor:[UIColor whiteColor]];
  return _tableView;
}

Remember also to connect your tableView in xib file, and it should work.

edzio27
  • 4,126
  • 7
  • 33
  • 48
  • This is bad practice, you're much better off doing this customisation in viewDidLoad (it's confusing and your UI calls will be repeated each time table is accessed) – Ege Akpinar May 17 '13 at 07:34
0

Without needing to write code, simply select Clear Color for the table view's Background property in the View section.

Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127