Changing icon colours in iOS using the tintColour property of UIImageView

Ashiq Sulaiman
Swift India
Published in
1 min readJan 9, 2018

So i was working on this application called Knappily, which is basically a knowledge app, i was asked to work on feature where there is a night theme which would change the colour of the background, text and images across all the screens of the application. Changing the colour of the background, images and text were easy, i used a library called NightNight. After a design change i had to include a lot of images to the Assets.xcassets. The Problem was i needed two different colours of the same icon. It took a some time for me to find the appropriate icons download them in different colours and resize. Later i figured out a way to avoid this method by using only one set of icon and changing the tint colour of the imageView. The implementation is really simple.

Step 1:

Select the image set for which you want to change the colour.

Step 2:

In the attributes inspector change the Render As option from Default to Template Image.

Step 3:

And that’s it. All you have to do now is testImageView.tintColor = UIColor.red

--

--