ios晋级之路-tableViewCell设置背景颜色

如果你项修改一下cell的颜色的话cell.contentView.backgroundColor = [UIColor redColor];

这样是没有问题的,但是如果你想把其修改成无色,那么就不可以了。

所以    

为了改变单元格的背景色,你需要修改

1
2
3
4
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor redColor]; 
}

contentView 仅仅是建议 subview 放入自定义控件,这样单元格能在表格编辑时适当的布局。

原文地址:https://www.cnblogs.com/fanxinguu/p/4747775.html