Artem Stepanenko Artem Stepanenko - 1 year ago 225
iOS Question

Modify UIImage renderingMode from storyboard/xib file

Is it possible to modify a

from a storyboard or xib editor?

The goal is to apply the
to the actual image.

Answer Source

Here's how you can do it in .xib or storyboard files:

Create a category on UIImageView:

@interface UIImageView (Utils)

- (void)setImageRenderingMode:(UIImageRenderingMode)renderMode;


@implementation UIImageView (Utils)

- (void)setImageRenderingMode:(UIImageRenderingMode)renderMode
    NSAssert(self.image, @"Image must be set before setting rendering mode");
    self.image = [self.image imageWithRenderingMode:renderMode];


Then in the Identity Inspector in the xib file, add a runtime attribute:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download