Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set UITextField height?

You can not change the height of the rounded rect border style. To set the height, just choose any border style other than rounded border in Xcode:

enter image description here


I finally found the fix for this!

As we have found, IB doesn't allow us to change the height of the rounded corner border style. So change it to any of the other styles and set the desired height. In the code change the border style back.

textField.borderStyle = UITextBorderStyleRoundedRect;

CGRect frameRect = textField.frame;
frameRect.size.height = 100; // <-- Specify the height you want here.
textField.frame = frameRect;

If you are using Auto Layout then you can do it on the Story board.

Add a height constraint to the text field, then change the height constraint constant to any desired value. Steps are shown below:

Step 1: Create a height constraint for the text field

enter image description here

Step 2: Select Height Constraint

enter image description here

Step 3: Change Height Constraint's constant value

enter image description here


1.) Change the border Style in the InterfaceBuilder.

enter image description here

2.) After that you're able to change the size.

enter image description here

3.) Create an IBOutlet to your TextField and enter the following code to your viewDidLoad() to change the BorderStyle back.

textField.borderStyle = UITextBorderStyleRoundedRect;

Swift 3:

textField.borderStyle = UITextBorderStyle.roundedRect

  1. Choose the border style as not rounded

enter image description here

  1. Set your height

enter image description here

in your viewWillAppear set the corners as round

yourUITextField.borderStyle = UITextBorderStyleRoundedRect;

enter image description here

  1. Enjoy your round and tall UITextField

Follow these two simple steps and get increase height of your UItextField.

Step 1: right click on XIB file and open it as in "Source Code".

Step 2: Find the same UITextfield source and set the frame as you want.

You can use these steps to change frame of any apple controls.