X code自动布局约束 - 为什么默认为负填充? [英] Xcode auto layout constraints - why defaulting to negative padding?

查看:151
本文介绍了X code自动布局约束 - 为什么默认为负填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我简单地增加一个UIView到视图控制器的主视图。我想的高度始终64PX,但宽度伸展到屏幕的宽度。

I am simply adding a UIView into the main view of a view controller. I want the height to always be 64px, but the width to stretch to the width of the screen.

然而,当我去添加约束,左,右填充默认为-16,即使观点是在其父视图捉襟见肘的所有道路。即使我设置这些回0,当我运行的应用程序的-16填充加回。这是怎么回事呢?

However, when I go to add constraints, the left and right padding default to -16, even though the view is stretched all the way across its parent view. Even if I set these back to 0, when I run the app the -16 padding is added back in. What is going on here?

推荐答案

取消选中的约束边距复选框销菜单(在问题的第一个图像),同时加入的间距的近邻的新限制。

Uncheck "Constrain to margins" checkbox in the pin menu (the first image in the question) while adding spacing to nearest neighbor for the new constraints.

这篇关于X code自动布局约束 - 为什么默认为负填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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