Michael
Michael

Reputation: 2099

iOS Storyboard - any way to change font size based on screen size?

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?

Upvotes: 3

Views: 8540

Answers (2)

Jack
Jack

Reputation: 14379

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.

enter image description here

Programmatically

label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.5

Upvotes: 4

LinusG.
LinusG.

Reputation: 28982

You can add variations inside the property inspector based on the different devices:

Property Inspector: Label

Note, however, that this will not distinguish between all devices...

Upvotes: 0

Related Questions