adjustsImageWhenHighlighted is deprecated and the header says this:
@property(nonatomic) BOOL adjustsImageWhenHighlighted API_DEPRECATED("This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler"
So far I have this
UIButtonConfiguration* buttonConfiguration =
[UIButtonConfiguration plainButtonConfiguration];
voice_search_button.configuration = buttonConfiguration;
voice_search_button.configurationUpdateHandler = ^(UIButton* button) {
};
but how do I make the image darker when highlighted/tapped? I should check if it's being highlighted and if it is then I add a tint to the UIButton? If so, what should that tint be to replicate the system color?
Thanks for the help!
Typically you would go one of two ways:
- Use a symbol image and allow UIButton to tint it – you can also customize this tinting behavior if you prefer (either
preferredSymbolConfigurationForImage
orimageColorTransformer
can be used to specifically target the image) - Supply an alternate image, either by selecting an alternate asset or generating one (presumably once and reusing it).
The specific style that UIButton uses is basically to mix the image with black at 45% alpha, but it isn't what UIButton does by default either.