2

,

I have this png image. How can I change this blue color (only) to a different color in swift. This because I might need to change to many different colors. Even better if its possible to change the black color to white.

vPhong
  • 41
  • 10
  • Possible functionality is: https://stackoverflow.com/questions/31803157/how-can-i-color-a-uiimage-in-swift/36591030 – Faysal Ahmed Jun 24 '19 at 05:23
  • 1
    This still only change the entire colored pixel to one color. Anyone have any ideal to achieve this? Like using svg file or something. I have done this in android by using LightingColorFilter. – vPhong Jun 24 '19 at 07:45

2 Answers2

0

you can try like this:

    self.img.image = self.img.image?.withRenderingMode(.alwaysTemplate)
    self.img.tintColor = UIColor.black
0
let tableImage: UIImageView = {
    let image = UIImageView()
    image.image = image.withRenderingMode(.alwaysTemplate)
    image.tintColor = .white
    return image
}()

try this, this will change your image tintColor. I don't think you can set mutiple colors in image

Habin Lama
  • 529
  • 5
  • 19