2

Okay I'm losing my mind here. Here is how my code is:

.plist

<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

Overrides

extension UINavigationController {
    open override var childForStatusBarStyle: UIViewController? {
        return topViewController
    }

    open override var childForStatusBarHidden: UIViewController? {
        return topViewController
    }

    open override var preferredStatusBarStyle: UIStatusBarStyle {
        return topViewController?.preferredStatusBarStyle ?? .default
    }
}

extension UITabBarController {
    open override var childForStatusBarStyle: UIViewController? {
        return children.first
    }

    open override var childForStatusBarHidden: UIViewController? {
        return children.first
    }
}

ViewController

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

I have went as far as crying for an update:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    setNeedsStatusBarAppearanceUpdate()
}

I know this has been asked and answered before and I have went through most if not all the answers on the platform and none could help. I don't know what to do anymore. Please help :(

Oh I tried this too

navigationController?.navigationBar.barStyle = .black

None of the override methods get invoked. THANK YOU

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116

1 Answers1

-2

Please try this it will help you. in AppDelegate class didFinishLaunchingWithOptions method write this.

UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent

it may helps you thank you.

Sanjukta
  • 1,057
  • 6
  • 16
  • 3
    This has been deprecated, that is why I use preferredStatusBarStyle. and this is a global set and I want to be able to set for individual ViewControllers – Castro Zwelithini Jan 08 '19 at 11:29