0

I am trying to change the selection color of a UITableview in my didSelectRowtIndexPath.

let selectedCellColor = UIColor.init(red: 97.0/255.0, green: 196.0/255.0, blue: 185.0/255.0, alpha: 1)

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
    print("tableView -> didSelectRowAtIndexPath")

    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)
    cell.contentView.backgroundColor = selectedCellColor
    cell.backgroundColor = selectedCellColor
}

Unfortunately, while the selection color changes, the text gets covered/invisible when I do this.

enter image description here

I did some searching but it seems this is the most recommended solution for changing the selection color of a standard UITableView cell.

I also tried changing the label color thinking it might get visible but no luck.

cell.textLabel?.textColor = UIColor.whiteColor()

What is it something that I'm missing?

daydr3am3r
  • 920
  • 4
  • 12
  • 31
  • 1
    you may find the answer [here](http://stackoverflow.com/questions/2418189/changing-background-color-of-selected-cell) – MudOnTire Apr 02 '16 at 14:42

1 Answers1

0

Thanks @MudOnTire. However, the problem was a bit different. It seems my textlabel.text property was always becoming empty on selection. Since I wasn't actually expecting something like this I never bothered to check.

daydr3am3r
  • 920
  • 4
  • 12
  • 31