Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable UITableViewCell highlighting?

I have a dark gray view background with a transparent tableview. I'm using the following code to try and stop cell highlight when a cell is clicked. It works except right when the cell is initially clicked, I see a highlight. I then transition to another scene after that. When I come back, the cell is not highlighted.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
    selectedCell.contentView.backgroundColor = UIColor.clearColor()
    tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

How do I disable the initial cell highlighting that is still going on?

like image 389
4thSpace Avatar asked Jul 20 '16 18:07

4thSpace


People also ask

How do I change the selection color of Uitableviewcell in iOS?

you can just change the backgroundView's backgroundColor property like so: cell. selectedBackgroundView?. backgroundColor = <your color .

How to remove selection color in tableView swift?

Inside the cellForRowAt indexPath method, on the table view cell, set the selectionStyle to . none .

How do I change the color of a selected cell in Swift?

Swift 3, 4, 5 select cell background colour Next connect your cell's selectedBackgroundView Outlet to this view. You can even connect multiple cells' outlets to this one view. Show activity on this post. For a solution that works (properly) with UIAppearance for iOS 7 (and higher?)


1 Answers

Set UITableViewCell selection style none

cell.selectionStyle = .None
like image 136
Sameer Subba Avatar answered Oct 14 '22 17:10

Sameer Subba