需要帮助设置两个等宽的按钮,并排自动布局 [英] Need assistance setting two buttons of equal width, side by side Autolayout

查看:29
本文介绍了需要帮助设置两个等宽的按钮,并排自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用自动布局我试图在底部创建两个按钮

拖动两个按钮后,我设置了这样的约束

Back button 上我设置了 Leading Space to Container MarginBottom Space to Bottom Layout Guide

转到设置按钮我设置了Trailing Space to Container MarginBottom Space to Bottom Layout Guide

然后我 ctrl+DragBack buttonGo 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆