setStatusBarHidden deprecated, but only thing that works

后端 未结 5 655
野的像风
野的像风 2021-02-05 18:22

I\'ve tried all the solutions I can find including those in: setStatusBarHidden is deprecated in iOS 9.0 but none of them work with my application.

It is a simple, single

5条回答
  •  误落风尘
    2021-02-05 18:34

    I've just been trying to solve the same problem, I don't know why the setStatusBarHidden and setStatusBarStyle have been deprecated as the new methods are not at all intuitive.

    To hide the status bar on launch I have these settings in my plist:

    View controller-based status bar appearance: YES
    Status bar is initially hidden: YES
    

    Then to show the status bar after launch I have in my view controller:

    - (BOOL)prefersStatusBarHidden {    
        return NO;
    }
    
    -(UIStatusBarStyle)preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    

    This still didn't work until I found this answer https://stackoverflow.com/a/19365160/488611. So in viewDidLoad I also set the navigation bar style:

    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    

    Which makes absolutely no sense, but works.

提交回复
热议问题