简体   繁体   English

如何在iOS Storyboard中使两个约束相互匹配?

[英]How do I make two constraints match each other in iOS Storyboard?

I have a view that is sized to the width of the screen with a 1x1 ratio of width to height (matching height). 我有一个视图,其大小与屏幕的宽度大小相同,宽度与高度(匹配的高度)的比率为1x1。 I have a view below that square view that is a set height from the bottom. 我在那个方形视图下面有一个视图,它是从底部开始的固定高度。 What I want is for the top view to be centered in the blank space. 我想要的是将顶视图居中于空白区域。 So I would love to just set 1 constraint for the top and 1 constraint for the bottom to say, match. 因此,我想只为顶部设置1个约束,为底部设置1个约束说匹配。 Then if there are x number of points of available, each constraint should be size x / 2. 然后,如果有x个可用点,则每个约束的大小应为x / 2。

So far, I haven't been able to find a constraint setting that can do this. 到目前为止,我还没有找到可以做到这一点的约束设置。 Could someone describe how to do this? 有人可以描述如何做到这一点吗?

通常,您添加2个透明视图,上方1个,下方1个,将边缘固定到现有视图,并将2个新视图设置为相等的高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM