我在视图控制器中有一个tableview,它使用数据库中的数据进行动态填充。现在我已经将tableview设置为清晰且工作正常,但我试图将单元格设置为清晰无效?
cell.backgroundColor = UIColor.clearColor()
该行已放置在cellForRowAtIndexPath函数中。
答案 0 :(得分:1)
这个小小的延伸可以帮助你。
我们的想法是将backgorundView
设置为清除,而不仅仅是backgroundColor
:
extension UITableViewCell {
func setTransparent() {
let bgView: UIView = UIView()
bgView.backgroundColor = .clearColor()
self.backgroundView = bgView
self.backgroundColor = .clearColor()
}
}
在cellForRowAtIndexPath
添加以下行:
cell.setTransparent()