[英]how to set background color + opacity in table view cell + style is grouped
我有一个分组样式的tableview
。 在这个我设置背景颜色clearcolor
像这样, cell.backgroundColor =[UIColor blackColor];
现在我想要这个单元格透明。 也许我可以用不透明度来做到这一点。 但在这我如何设置不透明度。
我想要这样的单元格背景 >>
这里不透明度。 我如何通过在单元格背景中编码来做到这一点?
您可以使用cell.alpha = 0;
那么你的单元格是不可见的,但所有的 textLabels 等等。
如果你只想要 cell.backgroundColor 有点透明,你可以使用cell.backgroundColor = [UIColor colorWithRed:0. green:0.39 blue:0.106 alpha:0.]
除了上面的答案。 您可以通过简单地设置单元格的 contentView alpha 来实现透明度。
cell.backgroundColor = .black
cell.contentView.alpha = 0.5
//. 将此添加到 viewdidload()
tableView.backgroundColor = UIColor.black
tableView.alpha = 0.65
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.