Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make custom image respect tintColor property iOS

I have to imagine this has been asked several times, but I must not be wording my question correctly.

I have my own custom image I made in photoshop and it is set as a button's image property. Here it is showing normally:

enter image description here

The background is transparent, but it is 44x44 with the three dots being a 88x88 pixel .png file. So if I do something like this:

self.theButton.tintColor = [UIColor redColor];

the image still shows as white. I am not a designer by trade, so I seem to be missing how to properly save or set up the files to make them respect the tintColor property. In photoshop, I usually save these using "Save for web".

Thanks

like image 935
Jason Renaldo Avatar asked Jan 02 '14 20:01

Jason Renaldo


1 Answers

Their are two way to set template image

1.Using Images.assets

enter image description here

2.Using Code

UIImage *myImage = [UIImage imageNamed:@"myImageFile.png"];
myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

imageView.image = myImage;
imageView.tintColor = [UIColor greenColor] // or any other color you want
like image 136
Kirit Vaghela Avatar answered Oct 14 '22 15:10

Kirit Vaghela