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