ios - UIImageView tintColor为整个图像着色

标签 ios tintcolor

我尝试通过将图标的渲染模式设置为UIImageView,然后通过调用来设置颜色来在点击后更改UICollectionViewCellTemplate Image的tintColor

iconView.tintColor = .blue

问题:它将用选定的颜色填充整个图像,而不是仅更改不透明的部分。

过去,这种方法对我一直有效,但我无法找出问题所在。我假设图标可能是白色背景而不是透明背景,但事实并非如此。也许与UIImageView内的UICollectionViewCell有关?

帮助将不胜感激!

最佳答案

尝试这个

imageViewHome.image = UIImage.init(named: "yourImageName")?.withRenderingMode(.alwaysTemplate)

imageView.tintColor = .blue

关于ios - UIImageView tintColor为整个图像着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41279220/

相关文章:

ios8 - UIAlertController 错误更改其他 UIImageViews 的 tintcolor

ios - GPUImageMovie 使用多个图像作为纹理和过程

ios - 如何在 Delphi FireMonkey iOS 应用程序中存储和播放媒体文件?

ios - 如何将 UIBarButtonItem tintcolor 设置为非默认 UIColor

ios5 - 更改 UINavigationBar 外观 backgroundimage 时,状态栏颜色更改

swift - 如何更改 SpriteNode 中图像的色调

ios - 如何更改现有 UIAlertAction 的标题?

ios - UIPIckerView:如何定义所选项目再次被选中?

iphone - 在 IOS 模拟器中访问摄像头

objective-c - UIButton 自定义边框中的 Tintcolor