3

I set the tintcolor of two system image buttons via storyboard, it works perfectly in all simulators and with ios13. but if I try with real Iphone 5s with ios 12.4 the two buttons are not displayed, the only things that properly works is button background color. I tried programmaticaly with plusBtn.imageView?.tintColor = .yellow or plusBtn.tintColor = .yellow. but it's the same,it works with ios13 but not with iphone 5s.

This is iphone 11 Pro simulator: enter image description here

and this is my real iphone5s device:

enter image description here

How can I set image tint color?

  • 2
    +1 Also reproduced the same - filled UIImage also loses color info with rendering mode = .alwaysOriginal. Since they come empty, not possible to set tint (template or original mode - doesn't matter.) iOS 11 device, same buggy result. Works OK with iOS 13. If you found any workaround, please post. – Nirav Bhatt Aug 05 '20 at 22:23

2 Answers2

2

You have to set the .withRenderingMode property to .alwaysTemplate for tintColor to work.

plusBtn.imageView?.image?.withRenderingMode(.alwaysTemplate)
Frankenstein
  • 15,732
  • 4
  • 22
  • 47
2

You can try setting the image programmatically but you have to remove it from Attributes inspector in storyboard :) it solved the bug in iOS 12

Jirson Tavera
  • 1,303
  • 14
  • 18