What is the replacement for UIButton.titleLabel.adjustsFontForContentSizeCategory in UIButtonConfiguration? If I want to replace UIButton.titleLabel in general, I need to create an NSAttributedString and then manipulate it, but I'm not sure if there's a NSAttributeKey for this property. Any help is appreciated! Feel free to add any other refactors that seem relevant!
The primary solution is to use a text style (e.g. UIFontTextStyleBody
) for your font, and then the configuration will adjust it automatically. If you plan to use a custom font, you may simply need to recalculate the font size inside your configurationUpdateHandler
. You can also use a titleTextAttributesTransformer
but you need to be careful to make sure your transformer produces a font that correctly matches (e.g. if you use a text style, then you also have resolved it to a specific content size category).
But if your using all the default stuff, you should get automatic resizing based on content size category without having to do any work. The above should only be necessary if your making customizations.