Search code examples
iostintcolor

How to prevent iOS decolorize image below a popover/alert


In my iPad app, images on UI elements with a tintColor and created with UIImage's .withRenderingMode(.alwaysTemplate), decolorize and become grey during the time a popover or alert is on screen. Because borderColor, which I set on some of these elements, is not affected, this looks off.

Why are these colors turned into grey? How can prevent this from happening?

I've seen this on iOS 10 and 11.

No Popover/Alert With Alert


Solution

  • You can set the tintAdjustmentMode of your view to .normal to turn it off, though IMO, you should override tintColorDidChange() and adjust your borderColor to .lightGray, or some other matching shade of gray, when tintAdjustmentMode == .dimmed. You can find out more here.