My initial view controller is a navigation controller and its root view controller is a UIViewController
which conforms to the UIPageViewControllerDataSource
protocol. The content for my pages are three unique view controllers which have both a scene in the storyboard and a swift file.
I am hiding the navigation bar in the root view controller's viewDidLoad()
.
self.navigationController?.navigationBar.hidden = true
When the app launches, the status bar is white and opaque. As soon as I scroll to the next page, it becomes translucent and the background color of the page shows through.
Appearance on Launch
Appearance While Swiping to Next Page
Can someone please help me understand what is happening here and how to fix it? In case it is not obvious, I want the second behavior from launch; the status bar is translucent and the page background shows through.
I have tried
- In
viewDidLoad()
:UIApplication.sharedApplication().statusBarStyle = .LightContent
In the root view controller:
override func preferredStatusBarStyle() -> UIStatusBarStyle { return .Default }
Followed by
self.setNeedsStatusBarAppearanceUpdate()
inviewDidLoad()
In the root view controller:
override func viewWillAppear(animated: Bool) { super.viewWillAppear(true) self.navigationController?.navigationBar.barStyle = .Default self.navigationController?.navigationBar.barTintColor = UIColor.clearColor() }
In
viewDidLoad()
(abovenavigationBar.hidden
):self.navigationController?.navigationBar.barStyle = .Default self.navigationController?.navigationBar.barTintColor = UIColor.clearColor()
As a note, when I remove the navigation controller and just make the root view controller the initial view controller, the status bar appears as expected- translucent.
This question is similar, but none of the solutions worked, it is over a year old, and when I contacted the poster, he said that he thought he put a view underneath where the status bar would be. I'm not sure that I can manage the the view in such a way that it works seamlessly with the scroll aspect of the page view controller.