Why do I have to set trailing space to -16 in Interface Builder to get full screen width?

寵の児 提交于 2019-12-24 15:34:50

问题


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.

来源:https://stackoverflow.com/questions/29875187/why-do-i-have-to-set-trailing-space-to-16-in-interface-builder-to-get-full-scre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!