Search code examples
iosswiftuiimageviewuiimage

Can't change colour of image


I've png images in assets I've set Render As Template image. Following is the code. Why doesn't it set the image to be white? How to fix it?

@IBOutlet weak var iconImageView: UIImageView!

iconImageView.image = UIImage(named: "ico")?.withRenderingMode(.alwaysTemplate)
iconImageView.tintColor = .white

Solution

  • Your code is fine and it's working perfectly. The only problem is the image is having transparency that's why color is not visible properly.