-1

I have view1 and view2 on screen. how can I make in auto layout that view1 height will be = 3.7 view2 height? Maybe that can be done by adding constraints in code. But I want to know all solutions.

Also how It can be done that view1 height will be = 3 view2 height? I think that can be done by adding 2 more views (viewAdditon1, viewAdditon2) . so that

view1 ,viewAdditon1, viewAdditon2 will have equal height. also view1.y top = view2.y top. and also viewAdditon1.y bottom = view2.y bottom.
viewAdditon1.y bottom = viewAdditon2.y top. viewAdditon2.y bottom = view1.y top.

Also question . How to make a square view? Or how to make that view1 height = 0.7 * view2 width?

Also question . How to make space between view1 buttom and view2 top = 1/4 view3 height? I know that can be done using view4 for this space. so view4 height = 1/4 view3 height . and view4 will be between view1 and view2. mabe there is other solutions?

  • Are you asking for a solution that does it in Interface Builder? – rob mayoff Jun 13 '15 at 04:12
  • I am asking for any solution. – userInStackoverflow Jun 13 '15 at 07:02
  • This question is way too broad. One question per question, please. Your question shouldn't be a laundry list of questions. Effectively, you're asking for a complete auto layout tutorial. And while I'm glad you're seeking these answers, the form of this question isn't even remotely a good fit for Stack Overflow. Either present a single, specific problem, and seek detailed help resolving that problem, or go find Apple's auto layout documentation and take some time to figure it all out. – nhgrif Jun 13 '15 at 18:18

1 Answers1

1

Here is an example of how to use autolayout to set a view 2/3 of the other view by storyboard:

Assuming that you have set all contains except height of this two views.

Now control drag from view2 to view1. Selected Equal Heights.

enter image description here

And then select this contains you added just now. Change the Multiplier to 2/3.

enter image description here

That's all.

enter image description here

Hope this can help someone.

JZAU
  • 3,550
  • 31
  • 37
  • Also question . How to make a square view? Or how to make that view1 height = 0.7 * view2 width? – userInStackoverflow Jun 13 '15 at 07:16
  • @userInStackoverflow here you can find out how to set square view http://stackoverflow.com/questions/15167607/width-equals-height-constraint-in-interface-builder and if feel free to up vote my answer, thank you! – JZAU Jun 13 '15 at 07:21
  • thanks again. I am not too cool user for vote up. Also question . How to make space between view1 buttom and view2 top = 1/4 view3 height? I know that can be done using view4 for this space. so view4 height = 1/4 view3 height . and view4 will be between view1 and view2. mabe there is other solutions? – userInStackoverflow Jun 13 '15 at 07:46
  • @userInStackoverflow yes using a hidden view4 is currently the best way to achieve that. – johnpatrickmorgan Jun 13 '15 at 10:16