如何动态地改变汽车的布局iOS上的字体大小? [英] How to dynamically change the font size in auto layout iOS?

查看:242
本文介绍了如何动态地改变汽车的布局iOS上的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想适合我的文本中的的UILabel ,但对于不同的iPhone 的UILabel 正在改变的大小,因为我使用的自动布局,但我不能修复的字体大小,所以我的文字切割出。

I want to fit my text in a UILabel, but for different iPhone the size of the UILabel is changing, as I'm using auto layout, but I cannot fix the font size, so my text is cutting out.

有什么办法,我可以设置任何限制,使文本在适合的UILabel 动态?

Is there any way I can set any constraint so that the text fits in the UILabel dynamically?

看到这里的文字得到了削减,因为不同的屏幕分辨率

推荐答案

您应该使用自动收缩

由于所有iPhone手机具有相同的紧凑型宽尺寸上课的时候​​在纵向模式下,你不能靠这个来处理您的标签尺寸。

Since all iPhones have the same Compact width size class when in portrait mode, you can't rely on this to handle your label size.

previews对于iPhone5的,iPhone6​​和iPhone 6 +

Previews are for iPhone5, iPhone6 and iPhone 6+

在这里输入的形象描述

在检查时,必须在自动收缩前选择最小字体比例或最小字体大小。这使得内容来改变字体的大小,以适应在标签

In the inspector, you must select minimum font scale or minimum font size in front of Autoshrink. This enables the content to change the size of the font to fit in the label.

在这里,我最小字体比例设置为0,5所以最小尺寸为当前大小的(31.0)的一半的。文本将试图适应直到达到最小规模/尺寸

Here, I set minimum font scale to 0,5 so the minimum size is half of the current size (31.0). The text will try to fit until it reaches the minimum scale/size.

(一般不要用拧紧字母间距为此,拧紧字母间距采用了相同的字体大小,并减少字母之间的间距。它可以使标签从2%到5%的更严格的截断之前,但它不是有效的,当最小字体规模/大小被启用。)

(Generally do not use "Tighten letter spacing" for this purpose. Tighten letter spacing uses the same font size and reduces spacing between letters. It can make label from 2% to 5% tighter before truncating, but it's not effective when minimum font scale/size is enabled.)

这是至关重要的模拟器来测试使用iPad临这是最像素的设备。

It is critical to test in the simulator using the iPad Pro which is the device with the most pixels.

要使它实际上在所有设备上工作,在故事板中选择一个大的离谱的字体大小(也许是300)。

To make it actually work on all devices, select a "ridiculously large" font size in Storyboard (perhaps 300).

安排你的设计的,使文本的填写的的UILabel

Arrange your design so that the text FILLS the UIlabel.

(如果你需要在你的文本的边框,这是微不足道的使用自动布局安排。)

(If you need a border around your text, this is trivial to arrange using autolayout.)

不要忘记测试的两个极端的设备在模拟器上,不管那些当你读到这封信的。 (目前4S和垫亲。)

Don't forget to test on the two extreme devices in the simulator, whatever those are when you're reading this. (Currently "4s" and "Pad Pro".)

这篇关于如何动态地改变汽车的布局iOS上的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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