问题描述
如何并排排列 3 个 UIButton.我正在使用自动布局.我的要求是:
How to arrange 3 UIButtons side-by-side.I am using Auto-layout. My requirement is:
1.无论设备如何,它们的宽度都应该相同
1.they should be equal width regardless of device
2.垂直占据视图的起点到终点
2.occupy vertically from starting to end of the view
我尝试了不同的方法,但未能实现.是否可以通过界面生成器实现
i tried different ways, i failed to achieve that. Is it possible through interface builder
推荐答案
有两种方法可以做到这一点.
There are 2 ways to do this.
方式一:
使用按钮的等宽限制
选择所有 3 个按钮并添加
Select all 3 buttons and add
上、左、右、高和等宽
方式2:使用堆栈视图
第 1 步: 添加 3 个按钮.
第 2 步: 选择所有按钮,选择后,单击右下角自动布局工具栏中的 堆栈按钮的故事板画布.见下图.
Step 2: Select all that buttons, Once you selected, click on the Stack button in the Auto Layout toolbar at the bottom right of the storyboard canvas. see below in image.
您也可以嵌入 From Editor -> Embed in -> StackView
第 3 步:将 约束 添加到 StackView.如下所示.
Step 3: Add Constraints to StackView. like below.
第 4 步:选择 StackView,选择后转到 属性检查器.将 Distribution 更改为 Fill Equally:
Step 4: Select StackView, Once selected go to Attributes inspector. Change the Distribution to Fill Equally:
它完成了!
这篇关于并排排列 3 个 UIButtons(等宽)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)