-1

I have this problem with tableView: despite I set all background fields with darkText color when I select a cell the background changes to the light one as you can see in the attached. How I could solve this issue?

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
wmi
  • 26
  • 5

2 Answers2

1

add cell.selectionStyle = .none in cellForRowAtIndex. This will remove the selectionColor from that cell

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier", for: indexPath)
    // do your cell customisation here..

    cell.selectionStyle = .none
    return cell
}
dRAGONAIR
  • 1,181
  • 6
  • 8
0

Try below method to disable cell selection when user interacts.

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
 let cell = tableView.dequeueReusableCell(withIdentifier: "yourCellIdentifier", for: indexPath)

 //Method 1: Simply disable the user cell interaction.
  cell.userInteractionEnabled = false
 //or
 //Method 2: use UITableViewCellSelectionStyle to none
  cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}
Joe
  • 8,868
  • 8
  • 37
  • 59