Rendering mode set to Template for vector pdf in image catalogue, but UIImageView wont tint the image in a custom cell

喜你入骨 提交于 2019-12-22 04:54:10

问题


I have migrated all my image files to the asset catalogue. All of them are pdf vectors of size 1x. They are set to render as a Template. They show up fine everywhere in size and in color. But there is this one custom TableView Cell from a xib that I has 6 UIImageView s linking to 6 of these images from the catalogue. Somehow they don't respect the tint color, neither default nor custom. Tried changing them programmatically but didn't work either. These same images show up fine in another tableview with static cells inside the main storyboard. I am not able to isolate the issue. Interestingly, the tint shows up perfectly fine once the cell is selected and the selection is changed. Then it tends to show the tint as set in IB. Seems to be like a bug to me in xcode. The problem exists in both, simulator and device. Any help?

PS: Already searched StackOverflow and the answers are all to change the rendering mode to template, which it is that way already.

Image Catalogue

Storyboard

Image before selection

image after selection


回答1:


Template image is work for something like UIButton.image but not UIImageView.image .

You have to set UIImage AlwaysTemplate by yourself.

imageView.image = [[UIImage imageNamed:@"image"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

And set rendering mode in imageAssets is not working in iOS 7.




回答2:


For some reason the initWithStyle method was not being called on the custom cells subclass. So I had to write the initialization code in awakeFromNib. The documentation for UITableView's dequeReuseableCell method clearly mentions that initWithStyle will be called even for custom cells, but it wasn't.



来源:https://stackoverflow.com/questions/29115346/rendering-mode-set-to-template-for-vector-pdf-in-image-catalogue-but-uiimagevie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!