Reputation: 33297
I have a UINavigationController
and a UIViewController
as its root view controller.
let rootVC = Page1ViewController() // extends UIViewController
let nav = UINavigationController(rootViewController: rootVC)
presentViewController(nav, animated: true) { () -> Void in
}
The problem is that the content of the rootVC appears under the navigation bar. I tried:
nav.navigationBar.translucent = false
this worked but I want the navigation bar to be transparent and I want the content of the rootVC not appear behind the navigation bar.
I also tried:
nav.edgesForExtendedLayout = UIRectEdge.None
but this does not change anything.
How can I get a transparent navigation bar where the content scrolls under it when scrolling but when loading the content should not appear under the navigation bar?
Upvotes: 2
Views: 4122
Reputation: 6899
To address your issue of a blackbox now appearing underneath your UINavigationBar
you need to set the presentation context properly. Try setting definesPresentationContext
on your UINavigationController
to NO
. This will then use the UIWindow
or parent of your UINavigationController
as the presentation context.
Upvotes: 2
Reputation: 2093
Remove this line:
nav.edgesForExtendedLayout = UIRectEdge.None
And add this line in your viewDidLoad from Page1ViewController
self.edgesForExtendedLayout = UIRectEdge.None
Hope it helps. Let me know if it doesn´t work and I will help you.
Upvotes: 9