字体自动缩小后,UILabel的内容大小不会更新

时间:2018-01-02 17:16:14

标签: ios swift autolayout uilabel

我在标题中有一个UILabel,当页面滚动时,它应该缩小。 我通过自动布局实现了这一点 - 我缩小整个标题的高度,然后缩小标签的高度,然后字体大小自动减小。

问题在于内容大小不会随着标签的字体大小而变化,从而导致看起来很有趣。

如何使用标签的字体更改来缩小内容尺寸?

这是UILabel的定义:

let lblGroup = UILabel()
lblGroup.adjustsFontSizeToFitWidth = true
lblGroup.numberOfLines = 0
lblGroup.setContentHuggingPriority(.required, for: .horizontal)

这是原始布局: enter image description here

这是在滚动之后: enter image description here

它们共享相同的内容大小: enter image description here

0 个答案:

没有答案
相关问题