24/01/2016 |
Comments:
0 |
Posted by: admin |
In:
IOS
With iOS7/iOS8/iOS9 you can color-fill a black-transparent png file, using the imageWithRenderingMode: method and the tintColor property.|
The iOS7/iOS8/iOS9: creates and returns a new image object with a specified rendering mode.
The rendering mode to use, is the UIImageRenderingModeAlwaysTemplate that draw the image as a template image, ignoring its color information.
Finally, the tintColor is the fill UIColor.

So, You can color-fill your png.
UIImage *img = [UIImage imageNamed:@"smile.png"];
self.imgOriginal.image = img;
self.imgColorFill.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.imgColorFill.tintColor = [UIColor colorWithRed:0.98 green:0.47 blue:0 alpha:1];
Awesome!
Read more →