Reputation: 477
I was wondering how I could create a UITextField that would create a new line when the text reaches it's edge.
Here how I am creating the text view:
UITextField *textField = [[UITextField alloc] init];
textField.frame = CGRectMake(0, 194, 320, 568);
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
textField.backgroundColor = [UIColor whiteColor];
UIView *textPaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 20)];
textField.leftView = textPaddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
[self.view addSubview:textField];
Upvotes: 1
Views: 82
Reputation: 130222
No, you shouldn't do that. UITextField
is only designed to have one line of text. The control that you should be using is UITextView
, which supports the behavior you've described natively.
Upvotes: 3