Re: Transparent Image with Tint Color
Re: Transparent Image with Tint Color
- Subject: Re: Transparent Image with Tint Color
- From: Kyle Sluder <email@hidden>
- Date: Sun, 29 Sep 2013 18:54:06 -0700
> On Sep 29, 2013, at 5:01 PM, Paul Scott <email@hidden> wrote:
>
> So, I successfully update the image src attribute within the UIWebView page using imageWithRederingMode:UIImageRederingModeAlwaysTemplate. However, the image appears "unrendered" with the tint color. Why?
Because you misunderstand how template images work.
-imageWithRenderingMode just returns a shallow copy of your UIImage that returns the passed value when asked for its renderingMode. It does not create an image that draws itself in the tint color. How could it? The image has no idea what view's tint color to adopt at initialization or at drawing time.
> How do I get an image rendered in the tint color?
Start a bitmap context, set your template image as the image mask, set the full color to the appropriate tintColor, and fill the bounds of the context.
Construct a data URI out of the image you get by closing the bitmap context.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden