Set background color on UITableView in IOS 6 [dupl

2019-03-15 06:40发布

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!

5条回答
男人必须洒脱
2楼-- · 2019-03-15 07:24

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

查看更多
聊天终结者
3楼-- · 2019-03-15 07:31

Did you try

addressNewTbl.backgroundView = nil;
[addressNewTbl setBackgroundColor:[UIColor redColor]];
查看更多
手持菜刀,她持情操
4楼-- · 2019-03-15 07:33

in cellForRowAtIndexPath datasource method.try setting

[cell setBackgroundColor:[UIcolor redColor]];
查看更多
在下西门庆
5楼-- · 2019-03-15 07:37

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..

查看更多
smile是对你的礼貌
6楼-- · 2019-03-15 07:43

You additionally need to disable the background view:

[addressNewTbl setBackgroundView:nil];
查看更多
登录 后发表回答