Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the cell highlight color of UITableView

In Swift:

cell.selectionStyle = UITableViewCell.SelectionStyle.none

or simply:

cell.selectionStyle = .none

In the Storyboard or XIB Attributes Inspector, set Selection to None.


Selection: None


Swift 3.0

cell.selectionStyle = .none

// Swift 2.0

cell.selectionStyle = UITableViewCellSelectionStyle.None

Objective-C:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

// or 

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

Swift 3+:

cell.selectionStyle = UITableViewCellSelectionStyle.none;

// or

cell.selectionStyle = .none

Swift 2:

cell.selectionStyle = UITableViewCellSelectionStyle.None

If you want to change it just using Interface Builder Storyboard/Xib, select the cell that you want to remove the "Selection Style Effect" and define it as "None". It'll work like magic as well :D

Storyboard / Xib