I have an UIImageView called "theImageView", with UIImage in a single color (transparent background) just like the left black heart below. How can I change the tint color of this image programmatically in iOS 7 or above, as per the tint method used in the iOS 7+ Navigation Bar icons?
Can this method also work in WatchKit for an Apple Watch app?
Best Answer
iOS
For an iOS app, in Swift 3, 4 or 5:
For Swift 2:
Meanwhile, the modern Objective-C solution is:
Watchkit
In WatchKit for Apple Watch apps, you can set the tint color for a template image.
To then set the tint color in Swift 3 or 4:
Swift 2:
To then set the tint color in Objective-C:
If you use a template image and do not apply a tint colour, the Global Tint for your WatchKit app will be applied. If you have not set a Global Tint,
theImage
will be tinted light blue by default when used as a template image.