Hide the status bar in ios 9

后端 未结 7 2224
小鲜肉
小鲜肉 2020-12-02 18:36

How do you hide the status bar in ios 9?

This is now deprecated:

 [UIApplication sharedApplication] setStatusBarHidden:YES];
7条回答
  •  时光说笑
    2020-12-02 19:17

    If for some reason you need View controller-based status bar appearance equal to YES (for example to keep status bar white)

    on AppDelegate's didFinishLaunchingWithOptions method or wherever you setup your navigationController:

    yourNavigationController.navigationBar.barStyle = .black
    

    then use alex-staravoitau's awesome answer and add this code wherever you'll be hiding the status bar:

    override var preferredStatusBarStyle: UIStatusBarStyle {
      return .lightContent
    }
    

    I'm not sure if this is the right way to achieve this result, but it worked for me and I hope it helps someone else too :)

提交回复
热议问题