Search code examples
xcoderotationautolayoutstoryboardconstraints

How to keep the same spacing when rotating the screen? (Autolayout)


I have two labels (vertically spaced). When switching to landscape, the spacing is slightly larger between the two. I want to keep the spacing the same no matter if I'm in portrait or landscape. I want to do this using the storyboard autolayout system, not through code.

I've messed with content hugging, content compression, and also changing the priority of vertical space constraints. Not sure if I was making the right adjustments.

Any help would be greatly appreciated.

Thanks in advance.


Solution

  • I found the solution. I just put vertical spacing between the labels and superview. I put the bottom label vertical constraint at 500 priority, and made sure that all the labels had vertical hugging priority of 501.