Search code examples
iosswiftuinavigationbaruinavigationcontroller

Navigation Bar pushes down view


In my application I have a UINavigationController, and the first view controller in the UINavigationController is the home screen. The UINavigationBar in the home screen doesn't appear. I want to keep anavigation bar on another screen. I turned the navigation controller off, but when you click a button which sends a segue to another screen, the UINavigationBar slides down animated and it pushes down a view which makes the view move down even though in storyboard, I set a constraint that the view should be 50 px below the navigation bar. Is there any way to stop the navigation bar pushing down the view?


Solution

  • Your constraint is probably set to the topLayoutGuide, rather than the top of the view. The top layout guide includes the UINavigationBar and Status Bar when present, but setting the constraint to the top of the view will not adjust for the UINavigationBar (or Status Bar, for that matter).