user3745888
user3745888

Reputation: 6253

How to keep tintColor in a UIButton then click on this?

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

Answers (1)

Syed Sadrul Ullah Sahad
Syed Sadrul Ullah Sahad

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

Related Questions