Reputation: 6253
I'm, setting the tintColor to the UIImageView of a UIButton like this:
UIImage* img = [UIImage imageNamed:imageName];
icon.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
icon.tintColor = [UIColor greenColor];
This code is working, but then Click the UIButton, the color return to the initial color of UIImage.
How could I keep the green color added?
Thanks!
Upvotes: 0
Views: 54
Reputation: 1312
Try like this if help.
UIImage *image = [[UIImage imageNamed:@“imageName.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[_yourBtn setImage:image forState:UIControlStateNormal];
[_yourBtn setTintColor:[UIColor greenColor]];
Upvotes: 1