Using Tint color on UIImageView Using Tint color on UIImageView xcode xcode

Using Tint color on UIImageView


Instead of this code:

[image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

you should have:

image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

Use this in Swift 4.1

image = UIImage(named: "name")!.withRenderingMode(.alwaysTemplate)


You can also just set this on your asset. Make sure your image contains all white pixels + transparent.enter image description here


(Can't edit @Zhaolong Zhong post)

In swift 3.0, you can do:

let image = UIImage(named: "your_image_name")!.withRenderingMode(.alwaysTemplate)yourImageView.image = imageyourImageView.tintColor = UIColor.blue