hide status bar swift 4

后端 未结 15 2058
无人及你
无人及你 2021-02-04 01:51

I am trying to hide status bar in one of my UIViewControllers (Swift 4).

  • Firstly, I set View controller-based status bar appearance to

15条回答
  •  不要未来只要你来
    2021-02-04 02:51

    As you said, you are using UINavigationController to navigate to your custom view controller. I suppose you have set your Custom View controller as the root view of your UINavigationController. In this case overriding var prefersStatusBarHidden in your custom view controller won't work but you will have to subclass your UINavigation Controller and override the property there as shown below:-

    class CustomNavigationController: UINavigationController {
    
        override var prefersStatusBarHidden: Bool {
            return true
        }
    
    }
    

提交回复
热议问题