Dom Shahbazi
Dom Shahbazi

Reputation: 730

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?

Upvotes: 1

Views: 1053

Answers (2)

Bista
Bista

Reputation: 7903

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.

Upvotes: 2

Mukul_3062
Mukul_3062

Reputation: 86

There must be problem with the constraint. First set your textField contraint to center vertically, center horizontally or remove one of the constraint upper or lower one.

Upvotes: 0

Related Questions