hide status bar swift 4

后端 未结 15 1851
无人及你
无人及你 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:47

    None of these worked for me either working on a converted project in iOS 11. Here's what I did. I added this code in the AppDelegate

    func application(_ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
    {
        application.isIdleTimerDisabled = true
        application.isStatusBarHidden = true
        return true
    }
    
    0 讨论(0)
  • 2021-02-04 02:50

    Just change "Top Space to" constraint of your view from Safe area to Superview. And it will drag your view under the Status bar so there is will be no need to hide it![enter image description here]1

    0 讨论(0)
  • 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
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题