Search code examples
iosuiimageview

How to tint a transparent png image in iOS?


I have a transparent png image with white background. Is there anyway to tint the transparent part? I tried many times but I can only tint the white background, not the transparent part. Thanks for your helps.

Update: Many thanks to zsnow.I laid a subview below the UIImageView. Then I set color for the subview.Voila, everything is Ok.


Solution

  • Create a UIView behind the UIImageView you are using and set the view's background color to the desired tint color and set the image view's background color to be transparent.

    tintView.backgroundColor = <desired tint color>;
    imageView.backgroundColor = UIColor.clearColor