问题
I want to be able to scale the font size on a storyboard per screen size without writing code to do this, is this possible.
I already tried to set up constraints to adjust the label and set the font scaling factor but what happens then it depending on how long the text is I end up getting a screen that has different font sizes rather than all of the font for that screen being the same size?
回答1:
Xcode provides auto shrinks facility, Which adjust based on screen size Goto Attribute inspector-> Autoshrinks -> Minimum font scale set it to 0.5 or your desired value.
Programmatically
label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.5
回答2:
You can add variations inside the property inspector based on the different devices:
Note, however, that this will not distinguish between all devices...
来源:https://stackoverflow.com/questions/43707915/ios-storyboard-any-way-to-change-font-size-based-on-screen-size