0
votes

Currently we are replicating a website sign-up screen to our native mobile application in iOS. As of now we are using the NSLayoutConstraints to programatically set the constraints between them. I tried to set up in the storyboard by providing the leading space and trailing space and height constraint between the UITextFields, but I wish to set the height constraints varying according to the different screens so that it looks the same everywhere as well as the vertical spacing. I'm hoping this can be without the coding part.

https://dribbble.com/shots/6006968-ReCars-Sign-Up-Login

Sign-up screen:

SignUpScreen

2
Can you please rephrase what you want to achieve? For me it's unclear what is meant by "But I wish to set the height constraints vary according to the different screens so that it looks the same everywhere as well as the Vertical spacing."carsten

2 Answers

1
votes

There are different ways to achieve this.

a> Don't use hardcoded height constraint for the textfield. Rather try to use relative constraint. Sample Relative Constraint Example . In the example I am giving height constraint to textfield with respect to its superview. So according to its superview its height will resize.

b> You can also explore Adaptive layout patterns. Where according to size class you can vary constraints.

0
votes

Like an option, you can setup equal height constraint of textfield with multiplier 1:N. I'll add images below.

But, I do not recommend it. Cause you will have a lot of problems with this solution. In my opinion, a better way to adjust your textfileds on screen is using UIScrollView, but in this way, you will work with the code.

First, add equal height for textfield and superview. Add constraint enter image description here

Second, set the multiplier. enter image description here

Hope it helps you

But remember better to make it properly once less than make it in a bad way then remake. :)