SnapKit / Masonry

Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout
MIT License
18.06k stars 3.15k forks source link

Label 使用label.numberOfLines来切换行数,上下文会莫名多出来一部分空白 #593

Open gulang-001 opened 3 years ago

gulang-001 commented 3 years ago
WX20210412-165327@2x WX20210412-165314@2x

使用的是masonry布局

1 2

有大佬知道如何处理吗?

gulang-001 commented 3 years ago

最后放弃使用numberOfLines=0;来适配高度,使用 YYTextContainer container = [YYTextContainer containerWithSize:CGSizeMake(self.detailLab.width, CGFLOAT_MAX)]; YYTextLayout layout = [YYTextLayout layoutWithContainer:container text:self.detailLab.attributedText]; numberOfLines = layout.rowCount; 计算出实际的行数进行赋值