为什么 UIViewController 中的子视图使用自动布局进行偏移

Why subviews in UIViewController going with offset using autolayout

无法理解为什么在新的 Xcode 中,当我从子视图向 controller.view

添加 0 leading/trailing 约束时,左右偏移量为 16.0f

A​​utoLayout 约束有一个设置Relative to Margin

如果您编辑约束并单击 first itemsecond item 下拉菜单,您将在其旁边看到一个勾号。

您需要取消选中此选项,然后 0 将与视图的边缘相关,而不是在 iPhone 上插入 16,在 iPad 上插入 24(我认为)。