Re: Confusion around tint color and UIImage rendering mode
Re: Confusion around tint color and UIImage rendering mode
- Subject: Re: Confusion around tint color and UIImage rendering mode
- From: Rick Mann <email@hidden>
- Date: Mon, 11 Jan 2016 17:33:23 -0800
> On Jan 11, 2016, at 17:24 , David Duncan <email@hidden> wrote:
>
>
>> On Jan 11, 2016, at 3:53 PM, Rick Mann <email@hidden> wrote:
>>
>> I have a UIButton subclass that does a lot of complex state changing, either replacing its image or drawing progress into itself. The images look like typical iOS 7+ icons, little blue outlines of things.
>>
>> This worked well in the regular view hierarchy, but now I need to add one to at UINavigationBar. I dropped it in and it made a UIBarButtonItem to contain it. Everything seems to work, but it draws blue. I realized this was because the image was blue.
>>
>> But as I investigated, it seemed that the actual drawn color depends on the UIImage's rendering mode, which was Default. I would've expected it to draw it as a template while applying the tint color when the view appeared in a nav bar, but it was blue. I tried changing the tint color of both the UIBarButtonItem and the UIButton in IB to white, but it still came out blue.
>>
>> So I changed the rendering mode in the Asset catalog for the image to Template. Now it draws correctly in the nav bar, but ALSO in the regular view hierarchy. That is, it's white in the nav bar (regardless of UIBarButtonItem or UIButton tint color), and blue in the regular view hierarchy.
>>
>> So, I'm a little confused. Any ideas what's going on?
>
> UIBarButtonItem does not explicitly convert the image to a template for rendering. You can do so by calling -imageWithRenderingMoe: on your source image.
Except in this case the image is a) inside a UIButton, and b) comes from an asset catalog where it's set to be a template.
--
Rick Mann
email@hidden
_______________________________________________
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