uitableview细胞的背景

问题描述 投票:1回答:5
MyTableCell *cell=[[MyTableCell alloc]init];
cell.backgroundColor = [UIColor clearColor];

上面的代码行仍然显示单元格背景的白色并隐藏了tableview的背景图像。

ios objective-c uitableview
5个回答
2
投票

转到你的故事板,并设置你的uitableview单元格的颜色,从那里清除颜色。并设置uitabelview颜色也清除颜色。

或者在viewdidload中设置tableview背景颜色以清除颜色,并在indexparth delagate中设置cellforrow

cell.contentView.backGroundColor = [UIColor ClearColor]

0
投票

试试这个

- (void)tableView:(UITableView *)tableView willDisplayCell(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath
{
 [cell setBackgroundColor:[UIColor clearColor]];
}

0
投票

同时设置contentview背景颜色

cell.contentView.backGroundColor = [UIColor ClearColor];
cell.backGroundView.backGroundColor = [UIColor ClearColor];
cell.selectedBackGroundView.backGroundColor = [UIColor ClearColor];

还要检查你是否也清除了tableView.backGroundColor


0
投票

谢谢大家。我已经解决了这个问题。我将故事板中属性检查器中的背景属性从我的单元格对象从默认更改为清除颜色并且工作正常。


0
投票

你可以这样做

cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];
© www.soinside.com 2019 - 2024. All rights reserved.