简体   繁体   English

Xcode自动布局约束 - 为什么默认为负填充?

[英]Xcode auto layout constraints - why defaulting to negative padding?

I am simply adding a UIView into the main view of a view controller. 我只是将UIView添加到视图控制器的主视图中。 I want the height to always be 64px, but the width to stretch to the width of the screen. 我希望高度始终为64px,但宽度要拉伸到屏幕的宽度。

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. 但是,当我去添加约束时,左边和右边的填充默认为-16,即使视图在其父视图中一直延伸。 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? 即使我将它们设置为0,当我运行应用程序时,会重新添加-16填充。这里发生了什么?

在此输入图像描述

在此输入图像描述

在此输入图像描述

取消选中pin菜单中的“Constrain to margins”复选框 (问题中的第一个图像),同时为新约束添加间隔到最近邻居

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM