Swift 3: UIImage when set to template image and changed tint color does not show image

For template images the background needs to be transparent - not white.


Template images work by using the opacity property of an image.

If you have an image with a transparent background then the transparent background remains transparent and ALL the rest of the image is changed to the tiny colour.

If your image does not have a transparent background. Say it has a white background. Then the entire image will be changed to the tint colour (like you are seeing in your example).

To fix this you need to give that image a transparent background.

It's also worth noting that you don't need that code. If you are using an image only in template mode then just select the rendering mode in the asset catalog.