How to change textfield height for an ipad using interface builder?

本秂侑毒 提交于 2019-12-05 18:23:42
Julian Osorio

It looks like the height of the rounded-style text field is locked in Interface Builder. My solution was to use another of the UITextField styles in my XIB and then call textField.borderStyle = UITextBorderStyleRoundedRect in my viewDidLoad method.

Of course, textField should be the name of the UITextField IBOutlet.

iOS UITextFields are single line only and have a fixed height.

If you want a multi-line, variable-height text entry field then use UITextView.

1 - Right click on your storyboard/xib file and select "Open as" -> "Source code".

2 - Find the xml tag relative to your TextField, e.g.

<textField opaque="NO" clipsSubviews="YES" tag="102" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="6872" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Dxw-lR-kq5">
<rect key="frame" x="20" y="337" width="335" height="30"/>

3 - Change the height value to what you want (e.g. 50)

4 - Right click again on you storyboard and select "Open as" -> "Interface builder"

5 - See the result

there is a wrapping text field,that is what you need.

amar

set the frame of ui textfield object in view did load but it will involve coding

[self.searchText setFrame:CGRectMake(180, 450, 400, 250)];
//in my case the object was called search text...

You can edit the height of any UITextfield in IB.Just set the constraint in IB.Select the constraint.In the Size Inspector-->Select and Edit just change the constant to your desired value.Press Enter ...Done!!!! (Can't get multiline though)

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