iOS的自动布局:宽度相等的两个按钮,并排 [英] iOS Autolayout: two buttons of equal width, side by side

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

问题描述

我目前具有自动版式困难。我使用界面生成器,我试图并排如下图所示定位宽度相等边的两个按钮。

I am currently having difficulty with AutoLayout. I am using interface builder and am trying to position two buttons of equal width side by side as illustrated in the following image.

从下面的preVIEW形象,我titleImage已适当约束,并且但是按钮不被正确显示。我已用titleImage的前缘,并与titleImage的后缘按钮2对准按钮1试验,但是两个按钮之间的宽度分布变得在这一点上偏斜,如下证实。

From the following Preview image, my titleImage has been properly constrained and is displaying correctly however the buttons are not. I have experimented by aligning button 1 with the leading edge of titleImage, and button2 with the trailing edge of titleImage, however the width distribution between the two buttons becomes skewed at this point, as demonstrated below.

我的目标是要了解哪些约束丢失并应适用于两个按钮保持相等的宽度无关的装置。如果可能的话我想通过界面生成器来实现这个,而不是额外的code。

My objective is to understand what constraints are missing and should be applied to the two buttons to maintain equal widths regardless of device. If possible I would like to achieve this through interface builder as opposed to additional code.

推荐答案

添加以下约束


  1. 从Button1的分配相等宽度按钮2。

  2. 分配水平间距两个按钮之间。

  3. 分配导致从Button1的空间,它的父。

  4. 分配尾随按钮2空间,它的父。

  5. 分配顶部空间,这两个按钮。


    让我知道它是否适合你。

这篇关于iOS的自动布局:宽度相等的两个按钮,并排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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