【问题标题】:Set UIImageView tintColor with multiple colors使用多种颜色设置 UIImageView tintColor
【发布时间】:2019-11-05 19:24:04
【问题描述】:

我有这个 png 图片。 如何快速将这种蓝色(仅)更改为不同的颜色。 这是因为我可能需要更改为许多不同的颜色。 如果能把黑色改成白色就更好了。

【问题讨论】:

  • 这仍然只是将整个彩色像素更改为一种颜色。任何人都有实现这一目标的理想?就像使用 svg 文件什么的。我已经通过使用 LightingColorFilter 在 android 中完成了这项工作。

标签: ios swift


【解决方案1】:

你可以这样试试:

    self.img.image = self.img.image?.withRenderingMode(.alwaysTemplate)
    self.img.tintColor = UIColor.black

【讨论】:

    【解决方案2】:
    let tableImage: UIImageView = {
        let image = UIImageView()
        image.image = image.withRenderingMode(.alwaysTemplate)
        image.tintColor = .white
        return image
    }()
    

    试试这个,这将改变你的图像 tintColor。我不认为你可以在图像中设置多种颜色

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多