如何调整标签大小以适合文本的长度 [英] How to adjust a label size to fit the length of the text

查看:119
本文介绍了如何调整标签大小以适合文本的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在过去的QAs中搜索了这个解决方案,但找不到合适的。

有谁知道如何调整 UILabel 动态大小以适应文本长度?

我上传了我不想要的屏幕截图(第一行)和我想要的(第二行)。

我感谢任何线索,建议或代码示例。谢谢。

I have searched the solution to this in the past QAs, but could not find the right one.
Does anyone know how to adjust aUILabel size dynamically to fit the text length?
I have uploaded the screen shot of what I don't want(1st line) and what I want(2nd line).
I'd appreciate any clues, advice or code sample. Thank you.

推荐答案

你在搜索的是UILabel方法 sizeToFit

What you are searching is the UILabel method sizeToFit

我可以尝试解释对你而言,知道如何使用UILabel的最佳答案是: https://stackoverflow.com/a/1054681/666479

I can try to explain to you, but the best answer to know how to work with UILabel is that: https://stackoverflow.com/a/1054681/666479

这篇关于如何调整标签大小以适合文本的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆