KirillC KirillC - 10 days ago 5
Swift Question

Update UI constraints in Xcode 8 for a specific device

As you can see on the image below my View Controller is packed with labels, everything looks good on iPhone SE but not on a larger screen phone. Is it possible to increase space between UI elements on iPhone 6,7,+ but keep same on SE without implementing Scroll View?

enter image description here

Answer

You can use Stack View, it will automatically set space for every device. Embed labels in stack view (Editor -> Embed In -> Stack View) and choose Distribution property that works for you ("Fill Equally" or maybe "Equal Spacing"). You can embed any view - also stack view (so you can have 12 stack views with label and result and embed them in external stack view for proper row spacing).

iPhone SE iPhone 7 Plus

Comments