Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable tableview cell highlighted color in edit mode?

enter image description hereHow can i remove the table view cell highlighted color in edit mode. I am using the table view property “allowsMultipleSelection” in edit mode. By default the cell is highlighted in a light blue color. Although we can change the highlighted color i have not seen any option to remove that highlighted color property. I want my table view cell checkbox selection only and not highlighted mode.

"cell.SelectedBackgroundView" allows to change the cell's background color when its selected, but i want to have only checkbox selection and no color for the cell in selected state.

Attached image of the screen. In my case the cell has a background image so on selection also I want the cell background to be same and only the checkbox selected.

like image 635
subin272 Avatar asked Mar 27 '18 17:03

subin272


People also ask

How do I change the color of a tableView selection?

you can just change the backgroundView's backgroundColor property like so: cell. selectedBackgroundView?. backgroundColor = <your color .

How do I turn off cell selection?

If you want to disable selection for just some of the cells, use: cell. userInteractionEnabled = NO; As well as preventing selection, this also stops tableView:didSelectRowAtIndexPath: being called for the cells that have it set.


1 Answers

UITableViewCell have selectionStyle property to highlight the cell on selection. These style highlight the cell with colour like:

Blue, Gray, Default(Light Gray), None

enter image description here

Upon selection of .none style, it will only prevent from highlighting the cell. It will not block the selection. You can see that by applying breakpoint in didSelectRowAt indexPath: function:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("UITableView Selected")
}
like image 63
Ankit Jayaswal Avatar answered Oct 20 '22 12:10

Ankit Jayaswal