从storyboard / xib文件修改UIImage renderingMode [英] Modify UIImage renderingMode from a storyboard/xib file

查看:119
本文介绍了从storyboard / xib文件修改UIImage renderingMode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从故事板或xib编辑器修改 UIImage renderingMode

Is it possible to modify a UIImage's renderingMode from a storyboard or xib editor?

目标是将 tintColor 应用于特定的 UIImageView 对象。 / p>

The goal is to apply tintColor to the particular UIImageView object.

推荐答案

以下是如何在.xib或storyboard文件中执行此操作:

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

UIImageView上创建一个类别

@interface UIImageView (Utils)

- (void)setImageRenderingMode:(UIImageRenderingMode)renderMode;

@end

@implementation UIImageView (Utils)

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

@end

然后在Identity Inspector中xib文件,添加运行时属性:

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

这篇关于从storyboard / xib文件修改UIImage renderingMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆