问题描述
如何设置自动布局在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
是俯视图
和底视图$之间C $ C>无间隙。
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的自动版式居中我的两个观点之间的看法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!