如何从SuperView的中心给约束一些余量 [英] How can I give constraints some margin from the center of superView

查看:73
本文介绍了如何从SuperView的中心给约束一些余量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自动布局.我有一个UIView发生在距超级视图中心20px的空白处.

I am using auto layout. I have one UIView that takes place at 20px margin from the center of the superview.

现在,我已经给了Top Space来监督我在iPhone 6+ Xib中所做的工作.但是当我在iPhone 4模拟器中运行时,它会掉得太多.

Right now I have given the Top Space to superview that i have make in the iPhone 6+ Xib. but when i run in the iPhone 4 simulator it goes to too much down.

任何想法

推荐答案

如果要相对于超级视图的中心放置视图,则应使用centerX和/或centerY约束,而不是顶部约束的观点.在IB中,如果选择容器中的垂直中心"约束以使视图垂直居中,则可以编辑该约束以更改其常数值,该常数值将使视图相对于中心偏移任意数量.

If you want the view to be placed relative to the center of the superview, you should be using centerX and/or centerY constraints, not a constraint to the top of the superview. In IB, if you choose the "Vertical Center in Container" constraint to center the view vertically, you can edit that constraint to change its constant value which will offset the view from the center by whatever number you choose.

这篇关于如何从SuperView的中心给约束一些余量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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