如何根据屏幕尺寸更改字体大小 [英] How do I change the font size according to screen size

查看:307
本文介绍了如何根据屏幕尺寸更改字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标签上添加了最小字体大小,但是字体并没有根据屏幕大小而变化。

I have added min font size to label but the font is not changing according to the screen size.

我认为设置最小字体大小并使用自动布局可以缩放标签高度足够。

I thought setting min font size and using autolayout is to scale the label height is enough.

但是它没有发生。

推荐答案

使用最小字体比例而不是最小字体大小。在IOS 6中不建议使用最小字体大小。在该图像中,尽管我说的是固定的,但是您可以更改它,然后设置比例因子。

Use minimum font scale instead of minimum font size. Minimum font size was deprecated in IOS 6. In the image although mine says fixed here you can change that and then set the scale factor.

要更改屏幕大小,您可以使用界面生成器来做一些。见图片。这是使用大小类。

To vary by size of the screen you can do some of that with interface builder. See image. This is using size classes.

其他方法是将字体大小增加到一个较大的数字并进行缩放,然后在代码中进行设置按设备类型,或在标签上设置约束以使其在不同尺寸之间增长和缩小,并设置缩放比例。

Other ways would be to increase the font size to a large number and let it scale, set it in code by device type, or set a constraint on the label to make it grow and shrink between different sizes and have the scaling set right.

这篇关于如何根据屏幕尺寸更改字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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