Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can UIButton background image support Dynamic Type?

After watching this talk I would like to support Dynamic Type in my app. It's easy for labels, but what about UIButton with an image set as a background? Image is in pdf, single scale and Preserve Vector Data. UIButton has Accessibility > Adjusts Image Size checkmark on but still it doesn't work. I haven't set any constraint for size for that button.

like image 315
Adam Smaka Avatar asked Nov 15 '25 20:11

Adam Smaka


1 Answers

The background image is scaled to fill the bounds of a UIButton.

The only way to enlarge this kind of image is by using the Dynamic Type and change the size as you noticed in the WWDC video you watched.

However, it's still possible to scale the image (not the background) and the font of your button using the text styles :

myButton.titleLabel?.adjustsFontForContentSizeCategory = true
myButton.adjustsImageSizeForAccessibilityContentSizeCategory = true

Finally, the background image only adjusts its size to the bounds of its button according to the accessibility Dynamic Type sizes used for its title label.

Besides, if you can't use the Dynamic Type in this case, you could take a look at the Large Content Viewer if need be ⟹ the UILargeContentViewerItem protocol is an iOS 13 new feature that shows the same HUD that's shown for standard bar items.

like image 107
XLE_22 Avatar answered Nov 17 '25 11:11

XLE_22



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!