我有一个带有 TableView 的 View ,以编程方式创建(没有 XIB 关联)。我希望某些单元格具有浅灰色背景色。 所以我尝试了这个:
cell.contentView.backgroundColor = [UIColor colorWithRed:(230/255.f) green:(230/255.f) blue:(230/255.f) alpha:1.0];
但这是结果(问题当然是单元格的背景应该完全是灰色的):
我也试过了,结果和之前一样:
UIView *cell_view = [[UIView alloc] init];
[cell_view setBackgroundColor:[UIColor colorWithRed:(230/255.f) green:(230/255.f) blue:(230/255.f) alpha:1.0]];
[cell setBackgroundView:cell_view];
似乎没有任何效果。感谢您的帮助。
最佳答案
设置tableviews的背景色为clear color。
tableView.backgroundColor = [UIColor clearColor];
关于ios - 为我的 UITableViewCell 设置背景颜色不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16940046/