Change color on checkmark in UITableView

后端 未结 15 2241
故里飘歌
故里飘歌 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:06

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

    self.tableView.backgroundColor = [UIColor clearColor];
    
    0 讨论(0)
  • 2020-12-07 23:07
    #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;
    
    0 讨论(0)
  • 2020-12-07 23:08

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

    UITableViewCell.appearance().tintColor = .green
    

    Nice little trick :)

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

    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.

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

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

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