0

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!

user3745888
  • 6,143
  • 15
  • 48
  • 97
  • 1
    Possible duplicate of [Why is my UIButton.tintColor not working?](https://stackoverflow.com/questions/11066008/why-is-my-uibutton-tintcolor-not-working) – Daniel Dec 24 '17 at 12:26

1 Answers1

1

Try like this if help.

UIImage *image = [[UIImage imageNamed:@“imageName.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        [_yourBtn setImage:image forState:UIControlStateNormal];
        [_yourBtn setTintColor:[UIColor greenColor]];