I have multiple views in a view and i need to increase the distance between these views based on the device. Very much like an aspect ratio type thing. How should I go about it using auto layout?
Asked
Active
Viewed 146 times
0
-
1Use spacing UIViews between the other views and vary the width of these views using an aspect rstio constraint related to the superview width – Paulw11 Jan 25 '16 at 12:21
-
I don't quite understand what you mean. I'm sorry, I'm a beginner. Can you guide me through it? – bigdaddy Jan 25 '16 at 12:25
-
http://stackoverflow.com/questions/13075415/evenly-space-multiple-views-within-a-container-view – Ankit Srivastava Jan 25 '16 at 12:27
-
http://stackoverflow.com/questions/17089427/ios-autolayout-vertically-equal-space-to-fill-parent-view – Ankit Srivastava Jan 25 '16 at 12:27
-
You need to understand the**Size Classes and auto layout** first. Then give a try will be easy to achieve ur task,..... – Kumar KL Jan 25 '16 at 12:30
-
Thanks you all, the answer below was very straightforward and easy to follow. – bigdaddy Jan 25 '16 at 12:33
1 Answers
2
Since you have more than one view, I recommend doing the following assuming this is the result you are looking for:
STEP 1 : select all your views
Step 2 : go to Editor -> Embed In -> Stack View (now it will group them together) I'm assuming that you set the width and height constraint for each of your views before doing this.
Step 3 : once you have done that select the stack (not the individual views). but rather the entire stack (I would do this from the side menu) and set the top layout and the bottom layout.
step 4 : Go here and make these settings for the stack as you have it selected
and that should do it. Let me know if I should clarify anything.

Unis Barakat
- 876
- 1
- 8
- 23
-
-
@bigdaddy, please accept answer if I answered your question. thanks :) – Unis Barakat Jan 25 '16 at 12:32