gpt4 book ai didi

ios - 在 UITableViewCell 上使用 IB 的 "User Defined Runtime Attributes"

转载 作者:可可西里 更新时间:2023-11-01 05:53:34 25 4
gpt4 key购买 nike

我有一个只有一个部分的静态 UITableView;该部分有两个 UITableViewCell,每个都有自己的 UIImageView(见屏幕截图)。我想修改单元格中使用的图像,以便它使用 UIImageRenderingModeAlwaysTemplate 的渲染模式(这样图像将遵循 tintColor)。

我选择了 UITableViewCell 并在 IB 的“用户定义的运行时属性”中设置了以下内容(见屏幕截图):注意:2 是 UIImageRenderingModeAlwaysTemplate 的值。

当我运行应用程序时,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.

知道我在这里做错了什么吗?另外,我不想为此编写代码 - 如果可能的话,我想坚持使用他们的 Storyboard。

谢谢!

enter image description here

enter image description here

最佳答案

由于 imageView.image.renderingMode 是一个只读属性,如果您不想继续编写代码,则必须执行其他操作。

完成此操作的最简单方法是在 Images.xcassets 中创建一个新条目。 xcassets 中的图像允许您选择渲染为:模板图像

enter image description here

关于ios - 在 UITableViewCell 上使用 IB 的 "User Defined Runtime Attributes",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25852890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com