[英]Using IB's “User Defined Runtime Attributes” on a UITableViewCell
I have a static UITableView
with a single section; 我有一个带有单个部分的静态
UITableView
; that section has two UITableViewCell
s each having its own UIImageView
(see screenshot). 该部分有两个
UITableViewCell
每个都有自己的UIImageView
(见截图)。 I would like to modify the image used in the cell so that it uses a rendering mode of UIImageRenderingModeAlwaysTemplate
(so that the image will honor tintColor). 我想修改单元格中使用的图像,以便它使用
UIImageRenderingModeAlwaysTemplate
的渲染模式(以便图像将尊重tintColor)。
I've selected the UITableViewCell
and set the following in IB's "User Defined Runtime Attributes" (see screenshot): Note: 2 is the value of UIImageRenderingModeAlwaysTemplate
. 我选择了
UITableViewCell
并在IB的“用户定义的运行时属性”中设置了以下内容(参见屏幕截图):注意:2是UIImageRenderingModeAlwaysTemplate
的值。
When I run the app Xcode generates the following warning: 当我运行应用程序时,Xcode会生成以下警告:
Failed to set (keyPath) user defined inspected property on (UIImageView): [<UIImageView 0x7fa490550d30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.
Any idea what I'm doing wrong here? 知道我在这里做错了吗? Also, I would like to not have to drop down to code for this - I want to stick with they Storyboard if possible.
此外,我不想下载代码 - 如果可能的话我想坚持他们的故事板。
Thanks! 谢谢!
Since imageView.image.renderingMode
is a read-only property you have to do something else if you don't want to drop down to writing code. 由于
imageView.image.renderingMode
是一个只读属性,因此如果您不想编写代码,则必须执行其他操作。
The easiest way to accomplish this is to create a new entry in Images.xcassets. 完成此操作的最简单方法是在Images.xcassets中创建一个新条目。 Images in xcassets allow you to select Render As: Template Image .
xcassets中的图像允许您选择“ 渲染为:模板图像” 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.