如何在 iPhone 中的标签中换行?

发布于 2024-08-18 10:12:32 字数 51 浏览 3 评论 0原文

我是 iPhone 开发新手。我想将文本包裹在标签中。我想包裹到标签中的特定位置。谢谢。

I am new to iphone development .I want to wrap up the text in the label.I want to wrap up to a particular position in the label.Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流殇 2024-08-25 10:12:32
 theLabel.lineBreakMode = UILineBreakModeWordWrap;
 theLabel.numberOfLines = 0;

这将让它换行任意数量的行。如果您想限制它们,并用“...”截断它们,则将 numberOfLines 属性设置为该值。

 theLabel.lineBreakMode = UILineBreakModeWordWrap;
 theLabel.numberOfLines = 0;

That'll let it wrap an arbitrary number of lines. If you want to limit them, and have it truncate with a “...”, then set the numberOfLines property to that value.

丢了幸福的猪 2024-08-25 10:12:32

将 Interface Builder ( http://drp.ly/d3K65 ) 中的“换行符”设置为“自动换行”并增加 UILabel 的高度。

您可以在代码中执行相同的操作(甚至更复杂),请参阅 UILabel 参考 http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UILabel_Class/Reference/UILabel.html

Set "Line breaks" in Interface Builder ( http://drp.ly/d3K65 ) to "Word Wrap" and increase height of the UILabel.

You can do the same thing (or even more complex) in the code, see UILabel reference http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UILabel_Class/Reference/UILabel.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文