How do I make a UITableViewCell appear disabled?

ma11hew28 picture ma11hew28 · May 6, 2011 · Viewed 39.7k times · Source

I know about UITableview: How to Disable Selection for Some Rows but Not Others and cell.selectionStyle = UITableViewCellSelectionStyleNone, but how do I make a cell (or any UIView for that matter) appear disabled (grayed-out) like below?

disabled UITableViewCell

Answer

Symmetric picture Symmetric · Nov 11, 2012

You can just disable the cell's text fields to gray them out:

Swift 4.x

cell!.isUserInteractionEnabled = false
cell!.textLabel!.isEnabled = false
cell!.detailTextLabel!.isEnabled = false