Set background color on UITableView in IOS 6 [duplicate]

无人久伴 提交于 2019-12-03 11:50:44

问题


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]];


来源:https://stackoverflow.com/questions/12617913/set-background-color-on-uitableview-in-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!