美文网首页iOS开发iOS Developer
设置UIImage的渲染模式:UIImage.rendering

设置UIImage的渲染模式:UIImage.rendering

作者: 传递正正正能量 | 来源:发表于2016-10-14 17:31 被阅读0次

最终效果图

注意注意图片的底色不能是白色,必须是透明的,否则不行

第一种方式,xcode直接设置如下

然后设置他的tintColor即可

self.addOneButton.tintColor= [UIColor blueColor];

第二种方式,代码设置如下

UIImage*img = [UIImage imageNamed:@"卖品_11"];

img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

self.addOneButton.imageView.image= img;

self.addOneButton.tintColor= [UIColor blueColor];

UIImageRenderingModeAutomatic  // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式。

UIImageRenderingModeAlwaysOriginal   // 始终绘制图片原始状态,不使用Tint Color。

UIImageRenderingModeAlwaysTemplate   // 始终根据Tint Color绘制图片,忽略图片的颜色信息。

相关文章

网友评论

    本文标题:设置UIImage的渲染模式:UIImage.rendering

    本文链接:https://www.haomeiwen.com/subject/oefnyttx.html