swiftuitableviewcheckmark

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?


Solution

  • 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