Search code examples
uitableviewappearance

How do I make a UITableViewCell appear disabled?


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


Solution

  • 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