为什么视图的边距必须为 -20 才能使其接近屏幕末尾,为什么不为零?

Why the view's margin has to be -20 to get it close to the end of the screen, why not zero?

截图:

看,前导、尾随和顶部是-20,但它应该是0。

基本上,我希望视图到达左侧、右侧和顶部的末端。

为了实现这一点,它应该是 0,但实际上,我必须给出 -20 才能实现。

我认为这与顶部和底部布局指南有关,但我不知道它是什么。

有人可以帮我吗?

您根据实际超级视图的 margin 设置约束,可能是视图控制器的主视图。为避免这样做,请在拖动约束时按住 Option,以便此菜单...

变成这样:

如果您已经创建了约束,请单击它并 select 尺寸检查器(右侧的第五个菜单)。检查第一项和第二项的属性和unselect Relative to margin in both.