UIViewController嵌套视图到屏幕边缘 [英] UIViewController Nested View To Screen Edge

查看:150
本文介绍了UIViewController嵌套视图到屏幕边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图控制器内部有一个嵌套视图,并且当我将前向和后向(到超级视图)约束设置为0时,子视图跨越了超级视图的左边缘和右边缘之间,在两侧都留有边距.如何删除此边距而不在约束中添加负值?

I have a nested view inside my view controller and when i set the leading and trailing (to superview) constraints to 0, the subview spans between left and right edges of the superview leaving a margin on both sides. How do I remove this margin without adding a negative value in the constrains?

推荐答案

假设您正在使用Xcode 6 ...

Assuming you're using Xcode 6...

设置关于边距的自动版式约束时,要记住两件事:

There are two things to keep in mind when setting Auto Layout constraints regarding margins:

Xcode默认使用新约束来包含边距.您可以在图钉"菜单上找到它-有一个默认为约束到边距"的复选框:

Xcode defaults new constraints to include margins. You'll find this on the 'Pin' menu - there's a checkbox that defaults to "Constrain to margins":

在上面的屏幕截图中,左侧和右侧约束都包含边距.取消选中此框将显示不包括边距的点距离:

In the above screenshot, the left and right constraints both include margins. Unchecking this box will show the distance in points not including the margins:

您可以通过选择约束并访问大小检查器"(右侧面板中的第5个图标,或Command + Option + 5)并编辑相对于边界的部分,将约束调整为不包括边界.访问下拉菜单,然后取消选择相对保证金"选项:

You can adjust a constraint to not include the margin by selecting the constraint and accessing the Size Inspector (5th icon in right-hand panel, or Command+Option+5) and editing the portion that is relative to the margin. Access the dropdown and unselect the "Relative To Margin" option:

请注意,常数值本身将保持不变,但是对象将调整并且不再考虑边距.

Note that the constant value itself will stay the same, but the object will adjust and not longer take the margin into consideration.

最后,我还没有找到一种方法来关闭此行为..我希望默认情况下不对边距设置约束,但是据我所知,使用Xcode 6.1.1时并没有改变这种行为的方式.

Lastly, I haven't found a way to turn this behavior off.. I would prefer to not have constraints set against the margins by default, but as far as I am aware with Xcode 6.1.1 there isn't a way to change this behavior.

这篇关于UIViewController嵌套视图到屏幕边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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