2

I have a png image which i want to fill with color.

I know about tint color, but it color only borders, i need to color inside the borders, like this desired result

Here I showed what I want to achieve

Angel F Syrus
  • 1,984
  • 8
  • 23
  • 43
nobody47
  • 41
  • 1
  • 3

1 Answers1

0

Try the below codes,

extension UIImageView {
  func setImageColor(color: UIColor) {
    let templateImage = self.image?.withRenderingMode(.alwaysTemplate)
    self.image = templateImage
    self.tintColor = color
  }
}

And you can call like:

let imageView = UIImageView(image: UIImage(named: "your_image_name"))
imageView.setImageColor(color: UIColor.purple)

Referred from here

Angel F Syrus
  • 1,984
  • 8
  • 23
  • 43