简体   繁体   English

UILabel:两行文字缩小

[英]UILabel: 2 lines text shrinking

By design (!) I have two lines title text which I cannot break: 按照设计(!),我有两行标题文本,不能中断:

JustWord
VeryLongWordWithoutSpaces

On big iPhones (6 and 6 Plus) text works great, 在大型iPhone(6和6 Plus)上,文字效果很好,
but when I test on smaller iPhone (5 or less) it looks like: 但是当我在较小的iPhone(5或更少)上测试时,它看起来像:

JustWord
VeryLongWordWi...

I cannot find a way how to shrink the text in UILabel. 我找不到一种方法来缩小UILabel中的文本。
Cutting and truncating are not possible in my situation. 在我的情况下,无法剪切和截断。

Requirements: 要求:
Auto Layout, no Storyboards, Swift 2.0, iOS 8.0+ 自动版面配置,无故事板,Swift 2.0,iOS 8.0+

做到这一点的两种主要方法是设置最小字体大小或最小字体比例。

Please try adjustsFontSizeToFitWidth: property for UIlabel. 请尝试为UIlabel调整AdjustsFontSizeToFitWidth:属性。 I have tried this and font is setting in one line and font size is automatically adjust. 我已经尝试过了,并且字体设置在一行中,并且字体大小会自动调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM