0

I want to create UIImage icon with different colors in PNG format. I have an original PNG UIImage. And If I set it with UIImageView with following code, I can easily get different UIImage with different tinted color appear in device:

self.imageView = [[UIImageView alloc] initWithImage:[originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
[self.imageView setTintColor:[UIColor whiteColor]];

My question is, after that, how can I export the tinted Image into PNG format so that I can use the image in other places. The origin of this question is when I use customer icon for SMPageControl, it only accepts UIImage and it seems you cannot get access to the UIImageView to set the tint color as above.

orignal image tinted image with white color

Johnson
  • 491
  • 1
  • 3
  • 13
  • Why do you want to do that? There may be an easier way. – Hermann Klecker Dec 30 '15 at 10:40
  • http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display – Hermann Klecker Dec 30 '15 at 10:41
  • http://stackoverflow.com/questions/14275859/convert-uiview-layer-to-uiimage – Hermann Klecker Dec 30 '15 at 10:41
  • http://stackoverflow.com/questions/5002789/get-uiimage-from-views-layers – Hermann Klecker Dec 30 '15 at 10:42
  • 4
    http://stackoverflow.com/questions/17145049/capture-uiview-and-save-as-image – Hermann Klecker Dec 30 '15 at 10:42
  • Have a look a the related questions. They all help you creating an UIImage out of the layer with all effects applied. That UIImage you can easily save as PHG with 3 or 5 lines of code. If you don't know how to do that then use the search function rather than asking that question again and again. There is lots of answerts about how to get the PNG representation from a UIImage and how to write to a file. – Hermann Klecker Dec 30 '15 at 10:44
  • The origin of this question is when I use customer icon for SMPageControl, it only accepts UIImage and it seems you cannot get access to the UIImageView to set the tint color as above. Your reply ( http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display) helps, thanks very much! – Johnson Dec 30 '15 at 10:49

0 Answers0