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?
Asked
Active
Viewed 332 times
-1
-
What do you want? Do you want to change the color, or turn off the selection color? – iphonic Apr 28 '17 at 19:26
-
Turn off the selection color – wmi Apr 28 '17 at 19:29
-
Possible duplicate of [How can I disable the UITableView selection highlighting?](http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting) – iphonic Apr 28 '17 at 19:30
-
Here is your answer http://stackoverflow.com/a/191245/790842 – iphonic Apr 28 '17 at 19:31
-
I would a blank selection color not disabling selection – wmi Apr 28 '17 at 19:35
2 Answers
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