Skip to content

Instantly share code, notes, and snippets.

@longvudai
Last active December 4, 2018 19:43
Show Gist options
  • Save longvudai/24d52b20a2ff8f73546e2f643e42eba2 to your computer and use it in GitHub Desktop.
Save longvudai/24d52b20a2ff8f73546e2f643e42eba2 to your computer and use it in GitHub Desktop.
preferredStatusBarStyle() to work within UINavigationController and UITabBarController
extension UITabBarController {
open override var childForStatusBarStyle: UIViewController? {
return selectedViewController
}
}
extension UINavigationController {
open override var childForStatusBarStyle: UIViewController? {
return visibleViewController
}
}
// MARK: - Usage
class ViewController: UIViewController {
// This will be called every time the ViewController appears
// Works great for pushing & popping with navigation or switch tabBar item
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment