Set background color on UITableView in IOS 6 [dupl

2019-03-15 06:41发布

问题:

Possible Duplicate:
Change background of a grouped UITableView

I am not able to change the background color of UITableView if it is UITableViewStyleGrouped. My code :

[addressNewTbl setBackgroundColor:[UIColor redColor]];

Help!

回答1:

You might need to add some code. Try -

[UITableView setBackgroundView: nil];

or you can also do :

UIView* bview = [[UIView alloc] init];
bview.backgroundColor = [UIColor yellowColor];
[tableView setBackgroundView:bview];

Both will work..



回答2:

Did you try

addressNewTbl.backgroundView = nil;
[addressNewTbl setBackgroundColor:[UIColor redColor]];


回答3:

You additionally need to disable the background view:

[addressNewTbl setBackgroundView:nil];


回答4:

Instead of setting the background color of the entire UITableView, try what happens when you set its backgroundView's background color.



回答5:

in cellForRowAtIndexPath datasource method.try setting

[cell setBackgroundColor:[UIcolor redColor]];