how can I make in auto layout that view1 height will be = 3.7 view2 height?

喜你入骨 提交于 2020-01-07 14:02:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!