大小相等的上海华在iOS 6中使用自动布局均匀空间UIViews [英] Evenly Space UIViews of equal sizes in superview using Auto Layout in iOS 6

查看:109
本文介绍了大小相等的上海华在iOS 6中使用自动布局均匀空间UIViews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个需要具有一系列的按钮被均匀地放置在水平的SuperView使用自动布局。
在这里,我想保持子视图的尺寸相同,只有子视图的中心将被放置在这样一种方式,有在它们之间的空间相等数目

I am in a need of having the series of buttons to be evenly placed in superview Horizontally using Auto Layout. Here, I want to keep the sizes of the subviews same, only the center of the subviews will be placed in such a way that there is equal number of space between them.

请注意:我不想设定的上海华的规模,我想每一件事情是自动布局-ED

Note: I dont want to set the Size of the superview, I want every thing to be Auto Layout-ed.

请帮助,
我坚持!

Please Help, I am stuck !!

谢谢!

推荐答案

您可以创建许多的UIView 的你有按钮,和中心的意见里面的按钮,视图可对准背靠背,使用这种code:

You can create as many UIView's as you have buttons, and center the buttons inside the views, the views can be aligned back to back, using this code:

[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view1][view2][view3]|"
                                                                         options:0
                                                                         metrics:nil
                                                                           views:views]];

请确保您第一次从上海华使用删除现有的限制:

Make sure you first remove existing constraints from the superview using:

[self.view removeConstraints:self.view.constraints];

和在viewDidLoad中关闭自动调整大小的转换:

and in the viewDidLoad turn off auto resizing conversion:

[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];

这篇关于大小相等的上海华在iOS 6中使用自动布局均匀空间UIViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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