如何添加间距相等和平等的宽度按钮,在iOS的自动布局 [英] How to add Equal Spacing and equal width for button in iOS Auto layout

查看:722
本文介绍了如何添加间距相等和平等的宽度按钮,在iOS的自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在X code新型为自动布局约束。我有一个底视图像的UITabBar 6 UIButtons 。如果没有限制,我对准这些按钮与5空间填充,每个按钮和每个按键有50个宽度。
现在,我尝试使用自动布局,支持所有屏幕尺寸做出来。

Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons. Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons has 50 width. Now,I am trying to make it by using Auto layout to support all Screen sizes.

在故事板制约了我设置的宽度相等的6个按钮和我做了60
  每个按键之间的空间。我把第一个按钮0领先的空间,
  我设置的最后一个按钮0到尾部的限制。

In Storyboard constrains I set equal width for 6 buttons and I made 60 space between each buttons. I set first button 0 to leading space and I set the last button 0 to tail constraints.

我要的,享有在所有器件尺寸之间是平等的宽度和灵活的空间按钮。

谁能恳求帮助我吗?寻找帮助。先谢谢了。

Can anyone pleas help me? Looking for the help. Thanks in advance.

推荐答案

检查该图像,并提出您的约束像下面...

check this image and made your constraints like below...

结果: - 在不同尺寸preVIEW

RESULT:- preview in different sizes

示例项目:

演示

请注意:如果你必须让应用程序适用于iOS 9及更高版本然后 UIStackView 是你的另一个选择。

NOTE: If you have to make app for iOS 9 and later then UIStackView is another option for you

这篇关于如何添加间距相等和平等的宽度按钮,在iOS的自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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