//方法一:
cell .contentView .backgroundColor = [ UIColor redColor ];
//方法二:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier :CellIdentifier];
UIView* bgview = [[ UIView alloc ] initWithFrame :CGRectMake( 0 , 0 , 1 , 1 )];
bgview .opaque = YES ;
bgview .backgroundColor = [ UIColor orangeColor ];
[cell setBackgroundView :bgview];
//方法三:
- ( void )tableView:( UITableView )tableView willDisplayCell :( UITableViewCell )cell forRowAtIndexPath :( NSIndexPath *)indexPath
{
cell .backgroundColor = [ UIColor redColor ];
}
参考:
如何设置UITableViewCell背景色
http://ios.9tech.cn/news/2013/1128/38946.html
本文详细介绍了三种方法来设置UITableViewCell的背景色,并提供了相应的代码示例。方法包括直接设置view的backgroundColor、使用自定义背景视图和在tableView数据源方法中设置背景色。
7549

被折叠的 条评论
为什么被折叠?



