多UIView的自动布局问题 [英] Multiple UIVIew Autolayout issue

查看:199
本文介绍了多UIView的自动布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个子视图一个的UIViewController它看起来像下面的图片第一子视图是屏幕的50%,其余三个子视图占据view.In剩余的50%的底部前25%其将占据2:1的比例range.remains由view.it的25%,占有将是定位在iPad横向视图正常,但在纵向视图首先查看超过70%占据。如何解决此

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

的UIView

推荐答案

我已经按照你想要创建的安装。请检查下面的截图。


以下是创建这个设置步骤:

1.添加四个视图到主视图。

2.添加龙头,顶部和棕色视图到主视图尾随空间的限制。

3.从紫以棕色视图中添加的垂直间距和领先的约束。

4.添加垂直间距,从绿色视图棕色视图尾随和平等的高度限制。

5.从绿色视图到主视图添加底部空间限制。

6.从紫着眼于绿色视图添加水平间距和宽度相等的约束。

7.增加垂直间距,领导,拖尾和平等的高度从橙色视图紫色视图约束。在尺寸检查从1这种平等的高度约束的倍数值更改为0.5(请参阅最后截图)。

8.从橙色着眼于绿色视图中添加底部约束。


1。意见情节提要:




2。视图层次和约束:




3。 iPad的屏幕截图在人像:




4。 iPad的屏幕截图景观:




5。尺寸检查:


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:

这篇关于多UIView的自动布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆