Kauna Mohammed
Kauna Mohammed

Reputation: 1137

How can I stop UIView background colour from disappearing when I select a cell in tableView

In my tableView, I have a subView with a background colour of red and anytime I select a cell in the tableview the background colour disappears. I was wondering if there was a way to fix this?

Upvotes: 0

Views: 103

Answers (2)

Swift Learner
Swift Learner

Reputation: 21

Try below code.

cell.selectionstyle = .none

Upvotes: 1

Shah Nilay
Shah Nilay

Reputation: 798

You have to stop tableview cell selection style. Write below code in cellForRowAtIndexPath method.

cell.selectionStyle = .none

For set cell background color on selection.

cell.contentView.backgroundColor = UIColor.red // here you can set your own custom color.

Upvotes: 1

Related Questions