Using IB's “User Defined Runtime Attributes” on a UITableViewCell

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I have a static UITableView with a single section; that section has two UITableViewCells each having its own UIImageView (see screenshot). 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).

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.

When I run the app Xcode generates the following warning:

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!

回答1:

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.

The easiest way to accomplish this is to create a new entry in Images.xcassets. Images in xcassets allow you to select Render As: Template Image.



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