Auto layout tutorial help

good day everyone ,
i am a new to ios development . i am following auto layout tutorial series of raywenderlich from youtube channel . i am trying to do all challenges thrown at the end of tutorial but i am stuck in this one . challenge is that i have to build a layout in which i have to set multiple textfields and button and the vertical space between them will adjust according to screen size or orientation. i just need hint that how i will set constraints priorites in this way that it will minimize and maximize the space between these elements according to screen size.

looking forward for positive response
thanks :slight_smile:

You should be able to use constraints that are relative to the screen size.

As in, change the MULTIPLIER… So instead of 1.0, make it… idk… 0.5? 0.2?

It depends how much you want it to scale, but it’s that easy. Once you have the constraint set up, it’s just a matter of setting the value you want.

NOTE: You cannot change the multiplier after it has been set. You must set the desired multiplier at the time of creation.

1 Like

you can always deactivate a constraint and create a new constraint with a new multiplier

cheers,

Jayant

1 Like

Correct!
You can even have multiple constraints on a ui element, and disable/enable (or active/deactive specifically) the one you want to show.

WARNING: For this to work (and NOT break your constraints), you should only enable 1 at a time. The second your app has a conflict, it WILL break and things won’t look good. I guarantee it.

I’ve actually put together a video of some common Swift mistakes and how to overcome them here: www.mypersonalcompass.com/swift-mistakes

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.