Reputation: 439
I have a tableview in a view controller that is dynamically populated with data from a database. Now I have set the tableview to be clear and it working correctly, but I have tried to set the cells to be clear to no avail ?
cell.backgroundColor = UIColor.clearColor()
That line has been placed in the cellForRowAtIndexPath function.
Upvotes: 0
Views: 664
Reputation: 11435
This little extension should help you.
The idea is to set the backgorundView
to clear too and not just the backgroundColor
:
extension UITableViewCell {
func setTransparent() {
let bgView: UIView = UIView()
bgView.backgroundColor = .clearColor()
self.backgroundView = bgView
self.backgroundColor = .clearColor()
}
}
In the cellForRowAtIndexPath
add the following line:
cell.setTransparent()
Upvotes: 1