Change color on checkmark in UITableView

后端 未结 15 2243
故里飘歌
故里飘歌 2020-12-07 22:31

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

相关标签:
15条回答
  • 2020-12-07 23:14

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

    enter image description here

    0 讨论(0)
  • 2020-12-07 23:16

    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()
    
    0 讨论(0)
  • 2020-12-07 23:17

    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!

    0 讨论(0)
  • 2020-12-07 23:19
     UITableViewCell *cell=(UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath];
    cell.tintColor=UIColor.whiteColor;
    return cell;
    
    0 讨论(0)
  • 2020-12-07 23:28

    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

    0 讨论(0)
  • 2020-12-07 23:30

    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]];
    
    0 讨论(0)
提交回复
热议问题