Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not changing status bar colour for UINavigationController #8

Open
chrisjingram opened this issue Aug 14, 2018 · 1 comment
Open

Not changing status bar colour for UINavigationController #8

chrisjingram opened this issue Aug 14, 2018 · 1 comment

Comments

@chrisjingram
Copy link

chrisjingram commented Aug 14, 2018

The first view controller in my UINavigationController has a transparent UINavigationBar (by setting the background image to UIImage()) with a dark image underneath - the status bar is set to lightContent correctly.

The second view controller sets the UINavigationBar background image to nil, and sets the background to light grey (in the viewWillAppear() lifecycle method) but the status bar remains lightContent, when it should display as the default black.

Is this desired behaviour for this module?

@chrisjingram
Copy link
Author

Found a workaround:

statusBarUpdater?.refreshStatusBarStyle() has to be called whenever the status bar should be refreshed - but this has to be called on the original instance of Bartinter that is watching for changes behind the status bar. In my case this was in the main root view controller called WrapperViewController. Unfortunately it doesn't work to simply call that function on the current VC.

I've set up a shared instance of WrapperViewController, and added the following lifecycle override to the view controllers in my UINavigationController:

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    WrapperViewController.shared.statusBarUpdater?.refreshStatusBarStyle()
  }

Would be nice to put this behaviour into the Bartinter module itself, but it will probably require method swizzling the viewDidAppear method. Not sure how safe that is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant