I have UIButton
s with images set that have white elements to them. The problem is that when UIButton.adjustsImageWhenHighlighted
is true
, then the white areas of the image are turned grey when pressing the button. I don't want UIButton
to have this effect on my image, so I set it to false
and it solves the problem. But now it is deprecated. What is the alternative solution to setting it to false
to achieve the same behavior without setting a .highlighted
image?
Replacement for `UIButton.adjustsImageWhenHighlighted`
Is there anything on this page that might help? https: // useyourloaf.com/blog/button-configuration-in-ios-15/
Deprecated doesn't mean "this does not work" it means "this is no longer maintained". In particular the deprecations from UIButton
are primarily meant to encourage migration to using buttons based on UIButtonConfiguration
(which does not offer this behavior out of the box, and so could be a solution to your issue).
But if updating to use UIButtonConfiguration
isn't reasonable at this time, and adjustsImageWhenHighlighted
continues to do what you need, then feel free to use it.