We're using Interface Builder for developing an app for the iPad and we can't figure out how to increase the height of the textfields.
When we were using IB to develop an application for osx, you could go to the textfields attributes and under the control section you could set line break to word wrap instead of clip.
When we try to use Interface Builder for iPad applications though, it doesn't have the option of changing linebreak style under attributes-->control.
Is there any way to set the height using Interface Builder or do you have to set that in the code?
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 UITextField
s 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.
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)
来源:https://stackoverflow.com/questions/3728522/how-to-change-textfield-height-for-an-ipad-using-interface-builder