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
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
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