4

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!

enter image description here

enter image description here

RobertJoseph
  • 7,968
  • 12
  • 68
  • 113
  • 1
    Have you tried setting this as a String type instead of Number? – Brooks Hanes Sep 15 '14 at 17:00
  • I've tried setting things like this: imageView.image.renderingMode String "2" or imageView.image.renderingMode String 2 or imageView.image.renderingMode String UIImageRenderingModeAlwaysTemplate – RobertJoseph Sep 15 '14 at 17:03
  • 1
    It looks like renderingMode is read-only. That means this wouldn't work to modify it. – Brooks Hanes Sep 15 '14 at 17:18
  • 1
    If you think this is the answer let me know and I'll post it in the answer for you to check. Otherwise I'll keep searching. – Brooks Hanes Sep 16 '14 at 15:31
  • 1
    @BrooksHanes As you said, since renderingMode is read-only I had to go another route. I'll post more when I can. Thanks again. – RobertJoseph Sep 16 '14 at 15:34

1 Answers1

2

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.

enter image description here

RobertJoseph
  • 7,968
  • 12
  • 68
  • 113