渲染模式设置为图像目录中的矢量pdf模板,但UIImageView不会在自定义单元格中设置图像 [英] Rendering mode set to Template for vector pdf in image catalogue, but UIImageView wont tint the image in a custom cell

查看:142
本文介绍了渲染模式设置为图像目录中的矢量pdf模板,但UIImageView不会在自定义单元格中设置图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将所有图像文件迁移到资产目录。所有这些都是大小为1x的pdf向量。它们设置为呈现为模板。它们在大小和颜色方面都显得很好。但是有一个来自xib的自定义TableView Cell,我有6个UIImageView链接到目录中的6个这些图像。不知何故,他们不尊重色调,既不是默认也不是自定义。尝试以编程方式更改它们,但也没有工作。这些相同的图像在主故事板内的静态单元格的另一个tableview中显示正常。我无法隔离这个问题。
有趣的是,一旦选择了单元格并且选择被更改,色调就会显示完全正常。然后它倾向于显示IB中设置的色调。在xcode中似乎对我来说就像一个bug。模拟器和设备都存在问题。任何帮助?

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:已经搜索过StackOverflow并且答案都是将渲染模式改为模板,就是这样。

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

图片目录

故事板

选择前的图像

选择后的图像

推荐答案

模板图像适用于UIButton.image但不适用于UIImageView.image。

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

你必须自己设置UIImage AlwaysTemplate

You have to set UIImage AlwaysTemplate by yourself.

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

并且在iOS 7中设置imageAssets中的渲染模式不起作用。

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

这篇关于渲染模式设置为图像目录中的矢量pdf模板,但UIImageView不会在自定义单元格中设置图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆