[英]Custom cell clear background?
我在一个视图控制器中有一个tableview,该控制器中动态填充了数据库中的数据。 现在,我已将tableview设置为clear且可以正常工作,但是我尝试将cell设置为clear无济于事?
cell.backgroundColor = UIColor.clearColor()
该行已放置在cellForRowAtIndexPath函数中。
这个扩展可以为您提供帮助。
这个想法是将backgorundView
设置为清除,而不仅仅是backgroundColor
:
extension UITableViewCell {
func setTransparent() {
let bgView: UIView = UIView()
bgView.backgroundColor = .clearColor()
self.backgroundView = bgView
self.backgroundColor = .clearColor()
}
}
在cellForRowAtIndexPath
添加以下行:
cell.setTransparent()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.