asheyla
asheyla

Reputation: 3325

Swift table view with a cell that is transparent and shows background image

I have tried to do so:

However I can not see the orange view behind the table view when I scroll and get to my cell, it just shows a grey cell.

Can somebody give me any hint to what else I should do?

Thank you

Upvotes: 3

Views: 2516

Answers (1)

ZGski
ZGski

Reputation: 2548

In your viewDidLoad(), add the code immediately below to set the tableView's background color.

tableView.backgroundColor = UIColor.clearColor()

In your cellForRowAtIndexPath method, use something similar to the code below to set a given cell's backgroundColor to be transparent, where the value 2 is the row of the cell you'd like to change.

switch indexPath.row {
case 2:
    cell.backgroundColor = UIColor.clearColor()
default:
    print("NOT Clear")
}

Upvotes: 2

Related Questions