ios - 更改 UIImage 基色,保持白色

标签 ios objective-c uiimageview uibutton uiimage

我正在尝试使用概述的方法 here用于更改用于 UIView 的 UIImage 的颜色。我希望这种方法会忽略空格,但事实并非如此。

这是我想用蓝色替换红色的原始图像。

enter image description here

这是代码

UIImage *image = [UIImage imageNamed:@"star-badge"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:...];
imageView.tintColor = [UIColor blueColor];
imageView.image = image;
[self.view addSubview:imageView];

但这是结果

enter image description here

有没有办法忽略空白或只改变红色?

最佳答案

更改原始图像,使中间透明而不是白色,然后您使用的方法应该可以工作。如果需要,将其显示在白色背景上。

关于ios - 更改 UIImage 基色,保持白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28354686/

相关文章:

ios - ** 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : 'Application tried to present a nil modal view controller on target

ios - 如何在存折上添加打开按钮

ios - 创建基于自动布局的指标 View

iphone - 自己的健康指标出现问题。 Cocos2d

iphone - 为 UIimage 添加边框

ios - 如何将 UIImageView 转换为 CGImageRef?

ios - 迭代 StackView,Swift

iOS:告诉用户是否未能输入解锁码

ios - 添加了 App Transport Security,仍然报错

ios - 垂直自动布局 subview