iOS 7 | Navigation bar / Toolbar buttons very close to status bar

ios7, uinavigationbar, uistoryboard, uitoolbar

Solution

The navigation bars or toolbars have to be at (0, `viewController.topLayoutGuide.length`) with bar positioning of `UIBarPositionTopAttached`. You should set the delegate of your navigation bar or your toolbar to your view controller, and return `UIBarPositionTopAttached`. If positioned correctly, you will have the result in your third image.

More information here: https://developer.apple.com/documentation/uikit/uibarpositioningdelegate?language=objc

Problem

I have a problem when dragging a navigation bar or toolbar (storyboard) to my view controller. UINavigationBar: As you can see in the image above, the right button is almost overlapping the status bar. With a UIToolbar it happens the same: This view controllers are intended to be used as a Modal, that's the reason I'm not using a UINavigationController. In another section I use a UINavigationController and it appears as I expect: How can I drag a UINavigationBar / UIToolbar to a view controller without overlapping the status bar?

Original source

Related problems