iOS Storyboard-是否可以根据屏幕大小更改字体大小? [英] iOS Storyboard - any way to change font size based on screen size?

查看:211
本文介绍了iOS Storyboard-是否可以根据屏幕大小更改字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在没有编写代码的情况下按屏幕大小在情节提要板上缩放字体大小,这是可能的.

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?

推荐答案

Xcode提供自动缩小功能,该功能可根据屏幕尺寸进行调整 转到属性检查器->自动收缩->最小字体比例将其设置为0.5 或您想要的值.

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.

以编程方式

label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.5

这篇关于iOS Storyboard-是否可以根据屏幕大小更改字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆