ios UITextField 多行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13475961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UITextField multiple lines
提问by Rudi
Just wonder if it is possible to use multiple lines in UITextField in XCode. I know how to increase the height size. but have know idea about its lines :/
只是想知道是否可以在 XCode 的 UITextField 中使用多行。我知道如何增加高度尺寸。但知道它的线条的想法:/
采纳答案by Rudi
Ok I did it with some trick ;) First made a UITextField and increased it's size like this :
好的,我用了一些技巧;) 首先制作了一个 UITextField 并增加了它的大小,如下所示:
CGRect frameRect = textField.frame
frameRect.size.height = 53
textField.frame = frameRect
Then I made a UITextView exactly in the same area that i made my UITextField, and deleted its background color. Now it looks like that I have a multiple lines TextField !
然后我在我制作 UITextField 的同一区域制作了一个 UITextView,并删除了它的背景颜色。现在看起来我有一个多行 TextField !
Check this: https://stackoverflow.com/a/13476467/1572408
回答by Wingpad
Unfortunately, UITextField is specifically one-line only. You will need to use a UITextView instead of UITextField for displaying and editing multiline text; it will be multiline by default.
不幸的是, UITextField 仅是一行。您需要使用 UITextView 而不是 UITextField 来显示和编辑多行文本;默认情况下它将是多行的。
回答by user1071136
You could use UITextView
instead, which is a "mini-notepad" view.
您可以UITextView
改为使用“迷你记事本”视图。