Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change UITableViewCellAccessoryType.Checkmark's color?

Here's my code:

cell.accessoryType = UITableViewCellAccessoryType.Checkmark

But when I run the app, I can't see the checkmark.

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

How to change checkmark's color to other colors like blue?

like image 738
PipEvangelist Avatar asked Jun 10 '15 17:06

PipEvangelist


2 Answers

Yes you can do it.

Just set the tintColor of 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 it from Attributes Inspector

OUTPUT

like image 137
Ashish Kakkad Avatar answered Nov 06 '22 02:11

Ashish Kakkad


Just set the tint color of UITableViewCell from Attribute Inspector or by coding like 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 check this hope it will work for you.

like image 11
Maishi Wadhwani Avatar answered Nov 06 '22 02:11

Maishi Wadhwani