如何去掉grouped样式UITableView中cell的边框和背景

2025-05-15 08:27:04
推荐回答(2个)
回答1:

把backgroundView设置为一个空的View,就可以去掉cell的边框和背景。

UIView *tempView = [[[UIView alloc] init] autorelease];
[cell setBackgroundView:tempView];
[cell setBackgroundColor:[UIColor clearColor]];

回答2:

_tableView.backgroundView = nil;可以搞定。
测试下发现确实可以,但是不知道以前的版本不确定有没有backgroundView的,所以最好加个判断吧:if(mainTableView.
backgroundView){
mainTableView.
backgroundView=nil;}如果类型为UITableViewStylePlain,[UIColor clearColor]仍然有效,怪哉!
正常情况下grouped样式(
UITableViewStyleGrouped
)UITableViewCell都是有边框的,如果要去掉边框可以用:
UIView *tempView = [[[UIView alloc] init] autorelease];
[cell setBackgroundView:tempView];
其实很简单,把backgroundView设置为一个空的View,然后就干净了。