Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gulang-001 opened this issue Apr 12, 2021 · 1 comment

Comments

@gulang-001
Copy link

gulang-001 commented Apr 12, 2021

WX20210412-165327@2x

WX20210412-165314@2x

使用的是masonry布局

1

2

有大佬知道如何处理吗?

@gulang-001
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant