iOS的自动版式居中我的两个观点之间的看法 [英] iOS autolayout to center my view between two views

查看:225
本文介绍了iOS的自动版式居中我的两个观点之间的看法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置自动布局在Interface Builder垂直排列的意见图像,如下所示:

How to set up autolayout in Interface Builder to arrange views vertically as shown on image:

俯视图固定顶部屏幕边缘,仰视图固定到下屏幕边缘。 我的看法要顶部和底部的观点(所以之间的距离为中心,以俯视图等于向<$ C $距离C>仰视图)

Top view pinned to top screen edge, Bottom view pinned to bottom screen edge. My view should be centered between top and bottom views (so distance to Top view equals to distance to Bottom view)

推荐答案

要做到这一点的方法是让你看到视图之间2隐形隔离的意见。

The way to do this is to have 2 invisible "spacer" views between you visible views.

您不能使空间具有高度相等。但您使用隔离的观点,并将其放置你的看法之间(0差距缩小到周围的景色)。

You can't make spaces have equal height. But you use the "spacer" views and place them between your views (with 0 gap to the surrounding views).

然后你给这些观点的高度相等,他们会推着你的意见,以中央的我查看等于差距,以底视图俯视图

Then you give these views equal heights and they will push your views around to centre the My View with equal gap to the Bottom View and Top View.

即。像这样...

V:|[Top View][spacer1][My View][spacer2(==spacer1)][Bottom View]|

编辑 - 另一种方式

我只是想到这样做的另一种方式。你可以有一个无形的容器的UIView 俯视图底视图无间隙。

I just thought of another way of doing this. You could have an invisible container UIView that is between Top View and Bottom View with no gap.

然后你把我查看这无形的看法和中锋里面垂直。

Then you place My View inside this invisible view and centre it vertically.

这篇关于iOS的自动版式居中我的两个观点之间的看法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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