iOS - 调整 UILabel 大小以匹配内容?
我有一个 UILabel 的行数为 0。 我在代码中设置了此 UILabel 的文本。 如何使 UILable 自行调整大小直到显示完整内容? 我不想占用任何空间,除非文本足够长,可以多行显示。
I have a UILabel with linecount of 0.
I set the text for this UILabel in code.
How can I make the UILable to resize itself until it displays the full content?
I don't want to take any space unless the text is long enough to be displayed in multiple lines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能正在寻找
[label sizeToFit];
这将使您的标签在您提供的文本上紧密裁剪。You may be looking for
[label sizeToFit];
That will get your label to crop tight on the text you give it.