Why do I have to set trailing space to -16 in Inte

2019-08-11 07:24发布

问题:

I'm building an iOS application and would like to have a menu that appears from the bottom and can be opened with an upwards swipe. Doing this programmatically works easily.

Since I would also like to learn how to do this in Interface Builder I gave it a try and now Interface Builder is driving me crazy.

What I did:

  • Create a new View Controller in story boards. Add the arrow so that this controller is shown first.
  • Add a view to the bottom of the View Controller's view. Let's call this view the menu.

  • Set constraints for the menu: leading space, trailing space and bottom space to superview to 0 and height to 100.

Seems like everything should be fine. But when I run the application, this is what happens:

Yellow is the background colour of the main view and red the background colour of the menu.

Only way to make the menu full width is if I set leading and trailing space to -16. But this does not make any sense to me!

Am I doing something wrong? I don't think this should be that complicated.