iPhone自动布局混乱

时间:2015-03-23 16:06:38

标签: ios storyboard interface-builder autolayout

我想按照下面的屏幕截图将2 UIButtons 放在一起。还显示了第一个 UIButton 的约束设置。

enter image description here

那些 UIButton 应该向上或向下扩展以适应iPhone 5,6或6 plus。但下面是我在iPhone 5上看到的内容。

enter image description here

我在哪里错过了要添加的约束?

3 个答案:

答案 0 :(得分:0)

1.Put both the buttons in UIView.
2.set constraints to UIView(Leading,Trailing,Top,Height)
3.set the satisfying constraints to the two buttons.

我认为这会让你完成。

答案 1 :(得分:0)

您可以单击水平线并将其标记为深红色,这意味着如果宽度增加,按钮应朝该方向展开

enter image description here

答案 2 :(得分:0)

无需容器视图。

button1.aspectratio = 1:1
button2.width = button1.width
button2.aspectratio = 1:1

button1.top to superview = 20
button1.leading to superview = 20
button1.trailing to button2.leading = 20
button2.top to superview = 20
button2.trailing to superview = 20

要添加宽高比限制,只需按住按钮即可从按钮拖动到自身(在左侧窗格中)。

enter image description here