Swift标签中的换行符和行数(以编程方式) [英] Line Breaks and Number of Lines in Swift Label (Programmatically)

查看:486
本文介绍了Swift标签中的换行符和行数(以编程方式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过在StoryBoard中选择一个标签,我可以将Line Break选择为Word Wrap,并将行数更改为大于1.如何在Swift中以编程方式做到这一点? /i.stack.imgur.com/uLhew.png"alt ="在此处输入图片描述>

By selecting a Label in a StoryBoard, I can select Line Break to be Word Wrap and change number of lines to be more than 1. How can I do that Programmatically in Swift?

推荐答案

您可以执行此操作以编程方式设置

You can do this to set it programmatically

 label.lineBreakMode = NSLineBreakMode.ByWordWrapping
 label.numberOfLines = 3

迅速3/4

label.lineBreakMode = .byWordWrapping
label.numberOfLines = 3

这篇关于Swift标签中的换行符和行数(以编程方式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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