[英]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.