iOS的自动布局如何水平拉伸2按钮 [英] iOS Autolayout how to stretch 2 button horizontally

查看:133
本文介绍了iOS的自动布局如何水平拉伸2按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从水平拉伸所有按钮:

I need to stretch all buttons horizontally from:

[button1][button2]

[  button1  ][  button2  ]

取决于屏幕的宽度。

depend on width of screen.

所以我寄托Button1以SuperView已经左上边缘。然后,我固定按钮2到Button1的水平,并设置等于高度Button1的,也寄托按钮2到右侧边缘。

So I have pinned button1 to superview for top and left edges. Then I pinned button2 to button1 horizontally and set equal height to button1 and also pinned button 2 to the right edges.

这是我的问题,现在:

推荐答案

您可以做这样的事情:

左键的水平限制:

1.的左键的平等的领先上海华的领导行为。

2.左键的尾随等于的centerX的上海华的(见下面的最后一个图像)。

Horizontal Constraints for the left button:
1. Leading of left button equals leading of superview.
2. Trailing of left button equals centerX of superview (See the last image below).

右键的水平限制:

1.的右键的领导行为等于尾随的左键的。

2.尾随的右键的等于结尾的上海华的。

Horizontal Constraints for the right button:
1. Leading of right button equals trailing of left button.
2. Trailing of right button equals trailing of superview.

请注意:根据你想要什么把垂直限制

Note: Put the vertical constraints according to what you want.

下面是一个样本截图:

这篇关于iOS的自动布局如何水平拉伸2按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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