iOS的自动布局保持距离2次距离 [英] iOS Autolayout keep distance from 2 views

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

问题描述

我想有固定在屏幕上方的一些看法,
其他一些在底部并在顶部和底部视图之间的距离相等的单一固定大小的图。

I'd like to have some views fixed on the top of the screen, some other on the bottom and a single fixed size view in the equal distance between the top and bottom views.

我无法弄清楚如何使用自动布局的限制做到这一点。我需要一些间隔的意见添加到用户界面,或者编程计算出所需的位置?

I cannot figure out how to do this with Autolayout constraints. Do I need to add some spacer views to the UI, or calculate the desired position programatically?

推荐答案

您可以只用一个附加的视图做到这一点。它会是这样的:

You can do this with only one additional view. It'd look like this:

stuff_on_top
middle_view (with fixed size view inside)
stuff_on_bottom

有会是之间的垂直空间约束 stuff_on_top &安培; middle_view 之间 middle_view &安培; stuff_on_bottom 固定大小的看法将水平和垂直方向的 middle_view 为中心。

There'd be vertical spacing constraints between stuff_on_top & middle_view and between middle_view & stuff_on_bottom. fixed size view would be centered horizontally and vertically in middle_view.

这样做,这将是两者的另一种方式把两个间隔的​​观点:与 stuff_on_top &安培; middle_view 之间 middle_view &安培; stuff_on_bottom 。然后,你会添加一个约束的间距意见高度是相等的。

The other way of doing this would be two put two spacer views: between stuff_on_top & middle_view and between middle_view & stuff_on_bottom. Then you'd add a constraint that heights of spacing views are equal.

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

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