需要帮助设置两个等宽的按钮,并排自动布局 [英] Need assistance setting two buttons of equal width, side by side Autolayout
问题描述
使用自动布局我试图在底部创建两个按钮
拖动两个按钮后,我设置了这样的约束
在 Back button
上我设置了 Leading Space to Container Margin
和 Bottom Space to Bottom Layout Guide
>
在转到设置按钮
我设置了Trailing Space to Container Margin
和Bottom Space to Bottom Layout Guide
然后我 ctrl+Drag
从 Back button
到 Go To Settings button
并设置 Equal Widths
代码>约束,我明白了.
然后我更新与 Go To Settings button
相同的 Back button
宽度,即 101
并且所有约束都变成蓝色.
但是无论屏幕大小如何,我都希望两个按钮都覆盖屏幕的一半,与第一个屏幕截图中所示相同,如何实现?
你可以像这样使用与第二个按钮等宽的按钮来完成
输出为
这里是 苹果指南
Using auto layout I am trying to create two buttons on the bottom like this
After dragging two buttons I set constraints like this
On Back button
I set Leading Space to Container Margin
and Bottom Space to Bottom Layout Guide
On Go To Settings button
I set Trailing Space to Container Margin
and Bottom Space to Bottom Layout Guide
Then I ctrl+Drag
from Back button
to Go To Settings button
and set the Equal Widths
constraint and I get this.
Then I update the Back button
width same as Go To Settings button
which is 101
and all constraints turn to blue.
But I want both buttons to cover half of the screen no matter what the size of screen is, same as shown in first screen shot, How to accomplish this?
you can done it using equal width to 2nd button like this
and the output is
Here is apple guide
这篇关于需要帮助设置两个等宽的按钮,并排自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!