简体   繁体   中英

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

I have a static UITableView with a single section; that section has two UITableViewCell s 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!

在此输入图像描述

在此输入图像描述

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 .

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM