Reputation: 468
Apologies if this is obvious, but why can I not tint an image within a UIImageView like I can tint an image as a UIBarButtonItem?
Thanks
Upvotes: 1
Views: 161
Reputation: 5828
You can in fact tint an image in a UIImageView.
Make sure that the tintColor
-property of your UIImageView is set to the color your want, and then make sure that your UIImage has the correct rendering mode. UIImageRenderingModeAutomatic
should work - but to force it to tint you can use UIImageRenderingModeAlwaysTemplate
.
You can change the rendering mode of an existing image like this:
UIImage *myImage = ...
myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
myImageView.image = myImage;
Please refer to the Apple Documentation on template images for more detailed information.
Upvotes: 1