ios - 需要帮助设置两个等宽的按钮,并排自动布局

标签 ios objective-c xcode autolayout

使用自动布局,我试图在底部创建两个按钮,如下所示

enter image description here

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

enter image description here

后退按钮 上,我将 Leading Space to Container MarginBottom Space to Bottom Layout Guide

Go To Settings 按钮 上,我将 Trailing Space to Container MarginBottom Space to Bottom Layout Guide

然后我将 ctrl+DragBack buttonGo To Settings button 并设置 Equal Widths 约束,我明白了。

enter image description here

然后我将 Back button 宽度更新为与 Go To Settings button 相同,即 101 并且所有约束都变为蓝色。

但是无论屏幕大小如何,我都希望两个按钮都能覆盖屏幕的一半,与第一个屏幕截图中显示的相同,如何实现?

最佳答案

你可以像这样使用与第二个按钮等宽来完成它

enter image description here

输出是

enter image description here

这里是 apple guide

关于ios - 需要帮助设置两个等宽的按钮,并排自动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29620409/

相关文章:

ios - 如何使用 Objective-C 的委托(delegate) Swift?

ios - 保存在应用程序中拍摄的照片并使用核心数据

ios - Facebook Audience Network 在 XCode 7 上有太多警告

带有 dismissViewControllerAnimated 的 iOS 8 错误 : completion: animation?

ios - IOS 中启动屏幕和初始屏幕之间的故障

objective-c - [Mac]如何在系统栏菜单中重现从cloudapp拖放?

ios - 如何在 iOS 中进行年龄验证?

ios - objectAtIndex :indexPath. 行方法在 IOS 中总是导致异常

objective-c - Swift 方法在 Objective-C 中不可见

ios - uicollectionview 的动态高度根据行值