【问题标题】:How to use autoresizing on UILabel font size如何在 UILabel 字体大小上使用自动调整大小
【发布时间】:2015-10-08 05:51:27
【问题描述】:

我在 storyboard 中使用 AutoResizing 而不是 AutoLayout。所有组件都将根据屏幕大小进行缩放。

但在 UILabel 上,字体大小不会改变。 我也希望它按比例缩放。 我该怎么办?

【问题讨论】:

标签: ios iphone xcode ipad autoresize


【解决方案1】:

您可以使用sizeToFit 实现此目的。sizeToFit 将根据其内容更改UILabel 的边界。

_yourLabel.numberOfLines = 0; #This will wrap text in new line
[_yourLabel sizeToFit];

【讨论】:

  • sizeToFit 使视图更改以适应字体大小,但我需要相反的。
猜你喜欢
  • 1970-01-01
  • 2011-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
  • 2021-11-24
  • 2011-02-28
  • 2014-05-04
相关资源
最近更新 更多