简体   繁体   English

自动布局Xcode 6

[英]Auto-Layout Xcode 6

I'm having some problems with Auto-Layout in Xcode 6 Beta, I have a ViewController and two buttons, and want them to occupy the entire area of view, each occupying half of it. 我在Xcode 6 Beta中遇到了自动布局问题,我有一个ViewController和两个按钮,希望它们占据整个视图区域,每个视图占据一半。

How I can do that? 我该怎么做? Whats constrains and ruler I have to apply? 我必须申请哪些约束和标尺?

截图

Thanks 谢谢

Select both buttons, open the constraints tab and set all the "Spacing to nearest neighbour" constraints to 0. This ensures that the 2 buttons will always fill the whole super view. 选择两个按钮,打开“约束”选项卡,并将所有“到最近邻居的间距”约束设置为0。这确保了2个按钮将始终填充整个超级视图。 By checking the Equal Heights option we ensure that both buttons get the same size, which will result in 2 50/50 height and 100% width filling buttons. 通过选中等高选项,我们确保两个按钮的大小相同,这将导致2个50/50高度和100%宽度的填充按钮。

https://www.dropbox.com/s/k4fnmqqblpc35st/Screenshot%202014-09-08%2002.59.22.png?dl=0 https://www.dropbox.com/s/k4fnmqqblpc35st/Screenshot%202014-09-08%2002.59.22.png?dl=0

For each one of the set Equal Heights constraint to the view(set the multiplier to 0.5). 对于视图的每个等高约束设置(将乘数设置为0.5)。 For the first button set top right, left constraint to 0. For the second button set bottom right, left constraint to 0. 对于第一个按钮,将右上角的约束设为0。对于第二个按钮,将右下角的约束设为0。

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

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