UITextField multiple lines [duplicate]

微笑、不失礼 提交于 2019-12-04 18:45:01

问题


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 :/


回答1:


Ok I did it with some trick ;) First made a UITextField and increased it's size like this :

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 !

Check this: https://stackoverflow.com/a/13476467/1572408




回答2:


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.




回答3:


You could use UITextView instead, which is a "mini-notepad" view.



来源:https://stackoverflow.com/questions/13475961/uitextfield-multiple-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!