简体   繁体   English

如何在Swift 3中调整字体大小以适合高度(而非宽度)

[英]How to adjust font size to fit height (not width) in swift 3

label.minimumScaleFactor works very well to fit the font to the width. label.minimumScaleFactor可以很好地适应字体的宽度。

However the font size, for alphabet such as "I", is typically larger than other letters such as "H". 但是,对于字母(例如“ I”),字体大小通常大于其他字母(例如“ H”)。 This makes the design very weird. 这使设计变得很奇怪。

I need help to fit the font to the label height. 我需要帮助以使字体适合标签高度。 Any solutions/functions/class that I can adopt? 我可以采用任何解决方案/功能/类吗?

Swift 3... 斯威夫特3 ...

label.minimumScaleFactor = 0.1    //you need
label.adjustsFontSizeToFitWidth = true    
label.lineBreakMode = .byClipping
label.numberOfLines = 0

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

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