9

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

Rudi
  • 4,290
  • 4
  • 32
  • 43

3 Answers3

6

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

var frameRect: CGRect = 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 colour. Now it looks like that I have a multiple lines TextField!

greybeard
  • 2,102
  • 7
  • 24
  • 58
Rudi
  • 4,290
  • 4
  • 32
  • 43
5

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.

Wingpad
  • 327
  • 1
  • 4
  • 12
  • but the problem is that i have problem with how UITextView looks like ! thanks anyway :) – Rudi Nov 20 '12 at 15:07
  • You can add UIImageView with needed image behind your UITextView. And set clearColor for text view. – EugeneK Nov 20 '12 at 15:58
3

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

user1071136
  • 15,468
  • 2
  • 38
  • 61