I have a UITableView
which is comprised of static cells. In IB I've set each UITableViewCell
's style to "Basic" and set an image (see screenshot). The buttons in my nav bar honor the tintColor
property but the images in the tableview do not. Thus far I've done everything in IB - do I have to use code if I want the images to honor the tintColor
property too?
Thanks
Every UIImageView
has the property tintColor
on iOS7+
Try to set cell's imageView.image.renderingMode
to UIImageRenderingModeAlwaysTemplate
in storyboard User Defined Runtime Attributes
The below setup worked for me well.
In the storyboard, set cell's contentView
tintColor
as your desired color and UIImagview
's tintColor
as default
.
What a headache this problem is after so many versions! The only thing that is a sure fire fix, assuming everything is "right" (template image, etc) is subclassing the UIImageView and overriding didMoveToSuperview with this...
- (void)didMoveToSuperview
{
[self setHighlighted:YES];
[self setHighlighted:NO];
[super didMoveToSuperview];
}
It's a hack but it works.
Here is an example:
UIImage *image = [[UIImage imageNamed:@"ic_email_white"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[[cell imageView] setImage:image];
[[cell imageView] setTintColor:[UIColor redColor]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With