简体   繁体   English

如何将文本设置为在快速uiTextField中分为两行

[英]how to set text to split into 2 lines in swift uiTextField

I have a uiTextField with dynamic text. 我有一个带有动态文本的uiTextField。

How can I set it via the editor to split the text into 2 lines (or more) 如何通过编辑器进行设置,以将文本分为两行(或更多行)

if text doesn't fit in the uiTextField width? 如果文本不适合uiTextField宽度?

Is there a way to do this not programmatically? 有没有办法以编程方式做到这一点?

Now text is seen as 现在文本被视为

"This is a long line" ===> "This is a long line" ===>

"This is...."

and I want it to be 我希望它成为

"This is a
 long line"

UITextField is one line only. UITextField仅是一行。 You can not have multi line content in UITextField . UITextField不能包含多行内容。 If you want to have multi line then use UITextView . 如果要多行,请使用UITextView

正如Vishnu所说,您需要对多行文本字段使用UITextview ,还需要在其中想将字符串分成下一行的位置添加“ \\ n”,例如"This is a\\nlong line"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM