I’m just trying to set adjustsImageWhenDisabled = false
. I get a deprecation warning but can’t find a simple solution. I can think of workarounds myself but this code adjustsImageWhenDisabled = false
is just so simple and works.
My "image" is just an image made out of a color using UIGraphicsBeginImageContext
. What I do now is that I override isEnabled
and on didSet
I set backgroundColor
if disabled otherwise I use setBackgroundImage(for:)
so that I get the highlighted effect when enabled.
And why does it not just work to use setBackgroundImage(for:.disabled)
?
2
Answers
Can you not try and set
.disabled
by setting the background image of the image.image.setBackgroundImage(disabledImage, for: .disabled)
You are getting the deprecated warning with message like "This property is ignored when using UIButtonConfiguration…" so, you can still use it with
UIButton
otherwise use theconfigurationUpdateHandler
like below: