我尝试通过将图标的渲染模式设置为UIImageView
,然后通过调用来设置颜色来在点击后更改UICollectionViewCell
内Template 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/