简体   繁体   中英

IS there a way to increase the height of the text field apart from increasing the font size

I am trying to increase the height of the UITextField in my app through IB. I have defined these textfield in my IB so i think it needs to be done through IB. Please let me know if there is a way to do it either through IB or through code.

Thanks,

As UITextField subclasses UIView, it inherits UIView's initWithFrame method.

NSInteger myCustomHeight = 237;
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, myCustomHeight)];

If u want do do it through IB then replace the last line with:

textField.frame = CGRectMake(10, 10, 200, myCustomHeight);

This assumes textField is an IBOutlet .

Increasing the height of UITextField is possible. But you cannot get text on next line, you can write text on only one line. It you want to have Textfield look alike you can use UITextView with editing option where you can increase the height and can have text on multiple lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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