Change color on checkmark in UITableView

Objective CUitableviewUicolor

Objective C Problem Overview


Could someone be so kind to show me how to change the color on the checkmark in UITableView?

I have searched but don't seem to get it to work.

Cheers

Objective C Solutions


Solution 1 - Objective C

Since the iOS SDK has changed since the accepted answer, I thought I'd just update with a new answer.

You can in fact change the color of the checkmark in a UITableViewCell by adjusting the tintColor property of the UITableViewCell.

You can also set an appearance proxy for all UITableViewCells so that ALL instances have a specific tint color unless otherwise specified

[[UITableViewCell appearance] setTintColor:[UIColor redColor]];

Swift: In Swift change the tintcolor to the color you want to change the color of any Accessory Type

cell.tintColor = .black

Solution 2 - Objective C

Apple doesn't provide a public way to change the color of the checkmark so you'll have to do it with an image.

This is very simple, just set the accesoryView property of the cell to a UIImageView containing a checkmark of the correct color.

It'll look like this:

UIImageView *checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coloredCheckmark.png"]];
cell.accessoryView = checkmark;
[checkmark release];

Enjoy!

Solution 3 - Objective C

If you are looking for a Swift version:

Directly on the cell

For example in tableView(_:,cellForRowAtIndexPath:)

cell.tintColor = UIColor.redColor()
Using the appearance protocol
UITableViewCell.appearance().tintColor = UIColor.redColor()

Solution 4 - Objective C

The following worked for me in iOS 7.

[self.tableView setTintColor:[UIColor someColor]];

Solution 5 - Objective C

This image shows how to do this in storyboards.The Tint color is the checkmark color.

enter image description here

Solution 6 - Objective C

I found that igraczech's answer is mostly correct, but with iOS 6 or later, you can just set the tint color of the entire tableview and default items will inherit down.

[self.tableView setTintColor:[UIColor someColor]];

This worked for me and allowed me to color in the checkmark.

Solution 7 - Objective C

Starting iOS 7 you could set the tint color of your view controller's view so that this tint colow will be propageted to all it's child views. So to set your UITableViewCell's checkmark as purple color (for example), in your viewWillAppear method you need to:

[self.view setTintColor:[UIColor purpleColor]];

Solution 8 - Objective C

The UIAccessoryTypeCheckmark (right side) inherits background color of its tableview.

self.tableView.backgroundColor = [UIColor clearColor];

Solution 9 - Objective C

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
HNCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HNCustomTableViewCell" forIndexPath:indexPath];
cell.tintColor = [UIColor colorWithRed:0.99 green:0.74 blue:0.10 alpha:1.0];
return cell;
}

It work for me.

Solution 10 - Objective C

 UITableViewCell *cell=(UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath];
cell.tintColor=UIColor.whiteColor;
return cell;

Solution 11 - Objective C

#import "UIImage+Color.h"
    
UIImage *image = [[UIImage imageNamed:@"ic_check_black_24dp.png"] changeColor:CLR_BUY];
UIImageView *checkmark = [[UIImageView alloc] initWithImage:image];
cell.accessoryView = checkmark;

Solution 12 - Objective C

I always used this easy way:

UITableViewCell *cell = ...;
cell.tintColor = [UIColor greenColor];
cell.accessoryType = UITableViewCellAccessoryCheckmark;

Solution 13 - Objective C

The above answers are all great. But if you want to do it globally, just do

UITableViewCell.appearance().tintColor = .green

Nice little trick :)

Solution 14 - Objective C

You don't have to use your own image, you can simply change it in your view did load with the following code.

[self.tableView setTintColor:[UIColor colorWithRed:250/255.0 green:223/255.0 blue:6/255.0 alpha:1]]

Cheers!

Solution 15 - Objective C

Swift 3.1, iOS 9+

if #available(iOS 9.0, *) {
            UIImageView.appearance(whenContainedInInstancesOf: [UITableViewCell.self]).tintColor = UIColor.themeTint //add your color here 
        } else {
            // Fallback on earlier versions
        }

Result

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeterKView Question on Stackoverflow
Solution 1 - Objective Cnvrtd frstView Answer on Stackoverflow
Solution 2 - Objective CAndrew ZimmerView Answer on Stackoverflow
Solution 3 - Objective CmokagioView Answer on Stackoverflow
Solution 4 - Objective CVinicius SouzaView Answer on Stackoverflow
Solution 5 - Objective Ckalan nawarathneView Answer on Stackoverflow
Solution 6 - Objective CBill BurgessView Answer on Stackoverflow
Solution 7 - Objective CRaunakView Answer on Stackoverflow
Solution 8 - Objective CigraczechView Answer on Stackoverflow
Solution 9 - Objective CAntony WongView Answer on Stackoverflow
Solution 10 - Objective CRaviteja MathangiView Answer on Stackoverflow
Solution 11 - Objective CGankView Answer on Stackoverflow
Solution 12 - Objective CEvsenevView Answer on Stackoverflow
Solution 13 - Objective CAustin-Michael KomatzView Answer on Stackoverflow
Solution 14 - Objective CRonaldoh1View Answer on Stackoverflow
Solution 15 - Objective CNitesh BoradView Answer on Stackoverflow