Dom Shahbazi Dom Shahbazi - 1 month ago 5
Swift Question

Autolayout - text field is vertically stretching when run in simulator

When I run my Swift app in an iPhone 6s simulator, the text field seems to be getting vertically stretched. The storyboard can be seen below:

Storyboard image

The app running in the simulator can be seen here:

enter image description here

I am not sure how to prevent this. I would like the bottom text field border to be closer to the placeholder text. Manually changing the height of the text field in the storyboard has not worked. I have constraints from each side of the text field to the respective side of the parent view. The storyboards are set to iPhone 6s and the simulator is set to iPhone 6s, surely the storyboard content should look almost identical in the simulator. Can anybody offer any assistance on this?


Remove the bottom constraint of the textfield! It is causing the textfield to increase height when view gets bigger.

To increase the size of the textfield with the size of device, you should add one more constraint: Aspect Ratio.