Pages

Tuesday 14 April 2015

How to change the UITextField's height in the Storyboard/Interface Builder?

When you design your interface for iOS, you can’t change the height of the UITextField directly in xib, when the textfield’s type is UITextBorderStyleRoundedRect. If you need a little taller text field, especially for iPad, either you have to do that in code or you have to change the text field type to some other. But this little trick will help you to do that in xib itself. 


If you are using the constraints, you may specify the height constraint for the textfield.

1. Give some identifier to your textfield, so that you can find your textfield easily in the next step.



2. Right click the storyboard/xib file, select Open As -> Source Code. The storyboard/xib is basically an XML, so its attributes can be edited directly. 



3. Search your textfield, and change its height attributes. I have given 40 for my textfield here.
<rect key="frame" x="195" y="152" width="211" height="40"/>



4. Now if you open your xib as Interface Builder - Storyboard file, by following the step 2, you will find your textfield’s height bigger.


Here is the video if want to take a look.






So easy as it looks like. You can also edit any attributes of any controls like this. But, make sure you don’t break the file format.

Besides, I am wondering why apple’s HIG don’t allow to change the text field height.

No comments:

Post a Comment