iPhone 自动布局混乱
iPhone autolayout confusion
我想按照下面的屏幕截图将 2 个 UIButtons 并排放置。还显示了第一个 UIButton.
的约束设置
那些 UIButton 应该放大或缩小以适应 iPhone 5、6 或 6 plus。但下面是我在 iPhone 5.
上看到的
我在哪里错过了要添加的约束?
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.
我想这会让你度过难关。
您可以单击水平线并将其标记为深红色,这意味着如果宽度增加,按钮应向该方向扩展
不需要容器视图。
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
要添加纵横比约束,只需按住 Ctrl 键并从按钮拖动到自身(在左窗格中)即可。
我想按照下面的屏幕截图将 2 个 UIButtons 并排放置。还显示了第一个 UIButton.
的约束设置那些 UIButton 应该放大或缩小以适应 iPhone 5、6 或 6 plus。但下面是我在 iPhone 5.
上看到的我在哪里错过了要添加的约束?
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.
我想这会让你度过难关。
您可以单击水平线并将其标记为深红色,这意味着如果宽度增加,按钮应向该方向扩展
不需要容器视图。
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
要添加纵横比约束,只需按住 Ctrl 键并从按钮拖动到自身(在左窗格中)即可。