Multiple UIVIew Autolayout issue

拈花ヽ惹草 提交于 2019-12-12 01:37:59

问题


I have an UIViewController with four subviews its look like below picture first subview is 50% of the screen and remaining three subviews occupy the remaining 50% of the view.In the bottom first 25% its will occupy the 2:1 ratio range.remains are occupy by 25% of the view.it's will be positioning the ipad landscape view properly but in portrait view first view more than 70% occupy. how to resolve this


回答1:


I've created the setup according to what you want. Please check the below screenshots.

Here are the steps to create this setup:
1. Add the four views into the main view.
2. Add leading, top and trailing space constraints from the brown view to the main view.
3. Add vertical spacing and leading constraints from the purple view to the brown view.
4. Add vertical spacing, trailing and equal heights constraints from the green view to the brown view.
5. Add bottom space constraint from the green view to the main view.
6. Add horizontal spacing and equal widths constraints from the purple view to the green view.
7. Add vertical spacing, leading, trailing and equal heights constraint from the orange view to the purple view. Change the multiplier value of this equal heights constraint from 1 to 0.5 in the size inspector (See the last screenshot).
8. Add bottom constraint from the orange view to the green view.

1. Views in Storyboard:


2. View Hierarchy and Constraints:


3. iPad Screenshot in Portrait:


4. iPad Screenshot in Landscape:


5. Size Inspector:



来源:https://stackoverflow.com/questions/34523257/multiple-uiview-autolayout-issue

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