How to change color of UITableViewCellAccessoryType.Checkmark?

Here is my code:

cell.accessoryType = UITableViewCellAccessoryType.Checkmark 

But when I launch the application, I do not see a checkmark.

Then I set the background color to black and I see a white checkmark.

How to change the color of a checkmark to other colors such as blue?

+15
uitableview swift
source share
3 answers

Yes you can do it.

Just set the tintColor cell.

 cell.tintColor = UIColor.whiteColor() cell.accessoryType = UITableViewCellAccessoryType.Checkmark 

Swift 3

 let aCell = tableView.dequeueReusableCell(withIdentifier: "Cell")! aCell.tintColor = UIColor.red aCell.accessoryType = .checkmark return aCell 

OUTPUT

You can also do this from the Attributes Inspector.

OUTPUT

+33
source share

Just set the hue color of the UITableViewCell from the Attributes inspector or by encoding as shown below

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellIdentifier = "SimpleTableViewCell" let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) // just add below lines cell.accessoryType = UITableViewCellAccessoryType.checkmark cell.tintColor = UIColor.red return cell } 

@ HenriqueGüttlerMorbin is testing this hope that it will work for you.

+9
source share

You can also set the color in your cell class (the one that is a subclass of the UITableViewCell class). Set the tintColor property in the awakeFromNib method if you want the same color to apply to all rows in your table view. Like this:

 override func awakeFromNib() { super.awakeFromNib() accessoryType = .checkmark tintColor = .red } 

Of course, if you set the color in the cellForRowAt method of your view controller, you can use the indexPath parameter to your advantage to set different colors according to the displayed string.

0
source share