Search code examples
iosstatusbar

prefersStatusBarHidden not called


I have a UITabViewController -> UINavigationController -> UIViewController and want to hide and unhide the statusBar. when I call setNeedsStatusBarAppearanceUpdate() the method prefersStatusBarHidden is not called.

func fadeOutStatusBar (notification: NSNotification) {
    statusBarHidden = true
    self.setNeedsStatusBarAppearanceUpdate()
}

func fadeInStatusBar (notification: NSNotification) {
    statusBarHidden = false
    self.setNeedsStatusBarAppearanceUpdate()
}

override func prefersStatusBarHidden() -> Bool {
    return statusBarHidden
}

Solution

  • Figured it out. in info.plist file: view controller-status bar appearance should be set to YES