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

本小妞迷上赌 提交于 2019-12-30 11:10:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!