Reputation: 9351
how can I change the tint color of the multiple selection checkmark?
I tried [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
in the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
method.
But it had no effect.
Am I restricted to the colors defined in the documentation of UITableViewCellSelectionStyle
so blue and gray?
Thanks
Upvotes: 4
Views: 2126
Reputation: 908
Swift 3.0
Just set the cell tint color in cellForRowAtindexPath for checkmark
cell.tintColor = UIColor.yourColor
and to change selection color set
let cellBackgroundColorView = uiview()
cellBackgroundColorView.backgroundColor = UIColor.yourColor
cell.selectedBackgroundView = cellBackgroundColorView
Upvotes: 4
Reputation: 1201
Note that in iOS 7, using
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
will not work as expected, because in iOS 7 this is now gray, even if you pass the constant above. See:
So use this to change color in the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method.
UIView *cellBg = [[UIView alloc] init];
cellBg.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // this RGB value for blue color
cellBg.layer.masksToBounds = YES;
Cell.selectedBackgroundView = cellBg;
Upvotes: 3