问题
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?
回答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
.
And then select this contains you added just now. Change the Multiplier
to 2/3
.
That's all.
Hope this can help someone.
来源:https://stackoverflow.com/questions/30814710/how-can-i-make-in-auto-layout-that-view1-height-will-be-3-7-view2-height