10 Replies
      Latest reply on Jun 3, 2020 9:13 AM by Luca_65
      Luca_65 Level 1 Level 1 (0 points)

        In iOS 12 and 13, up to 13.4, few lines of codes:

        navigationController?.navigationBar.isTranslucent = false

        navigationController?.navigationBar.barTintColor = .black

        navigationController?.navigationBar.tintColor = .red

        allow to hide the status bar under the navigation bar.

        With swiftUI is perhaps even simpler

        .statusBar(hidden: hideStatusBar)

        but it requires to rewrite the whole app from storyboard to swiftUI.

        Hiding the status bar, or go to full screen, is still be possible without using swiftUI on legacy code?

        • Re: Hide StatusBar on iOS 13.5
          Claude31 Level 8 Level 8 (9,215 points)

          Why this question ? Have you found problem with iOS 13.5 with those 3 lines of code ?

           

          I would avoid rewriting in SwiftUI. You may solve one specific point and create 10 more…

            • Re: Hide StatusBar on iOS 13.5
              Luca_65 Level 1 Level 1 (0 points)

              With iOS 13.5 that lines of codes doesn’t hide anymore the status bar. I agree with you in preferring to modify some lines of codes than re-develop the app in SwiftUI.

                • Re: Hide StatusBar on iOS 13.5
                  Claude31 Level 8 Level 8 (9,215 points)

                  OK, the 3 lines mask the status bar.

                   

                  Have you checked in the VC (Attributes inspector for the VC itself) how transition and presentation are defined ? Test with fullscreen instead of automatic.

                    • Re: Hide StatusBar on iOS 13.5
                      Luca_65 Level 1 Level 1 (0 points)

                      Thanks Claude,

                      The VC Attribute Selector "Layout / Use Full Screen (Deprecated)" has no effect.

                      I also tryied the VC attributes "SImulated Metrics", which infer the canvas but not the iPhone, as its title describes, and the Layout attributes, all without effect.

                      In the info.plist I added "UIStatusBarHidden = YES"; It immediately changes to "Status bar is initially hidden = YES" and works for the LaunchScreen only.

                        • Re: Hide StatusBar on iOS 13.5
                          Claude31 Level 8 Level 8 (9,215 points)

                          I'm not sure we speak of the same thing.

                           

                          What I described:

                          - In IB, select the first VC. Select the VC itself.

                          In Attributres Inspector, you should see sections :

                          - Simulated metrics

                          - View Controller

                               Here, look at Presentation. What is it ?

                               Turn it to Fiull screen

                           

                          I do not see it deprecated anywhere. Unless it is in iOS 13.5 (did not install yet).

                            • Re: Hide StatusBar on iOS 13.5
                              Luca_65 Level 1 Level 1 (0 points)

                              Thank you Claude for the clarification.

                              Before I've pointed to "Use Full Screen (Deprecated)". I verified with Presentation: Full Screen and Over Full Screen. In all cases the status bar is visible on the iPhone with iOS 13.5 (last beta).

                                • Re: Hide StatusBar on iOS 13.5
                                  Claude31 Level 8 Level 8 (9,215 points)

                                  What I do not understand is that hiding status bar depends on where the nav bar is positioned.

                                   

                                  Where is it positioned in your case ? Over status bar ? How do you position it here ?

                                  Where do you put the 3 lines of code ?

                                  In viewDidload ?

                                  TRry in viewWillAppear or viewDidAppear.

                                   

                                  Maybe (need to check with iOS 13.5) they have changed a bit the sequence to display statusBar ?

                                    • Re: Hide StatusBar on iOS 13.5
                                      Luca_65 Level 1 Level 1 (0 points)

                                      I found the issue origin, which is correlated to the Dark Mode (that I had inadvertently changed)

                                      The 2 codes' lines:

                                      navigationController?.navigationBar.isTranslucent = false
                                      navigationController?.navigationBar.barTintColor = .black

                                      determine a dark background of the statusBar.

                                      In Light Mode the StatusBar foregroundColor is black so it disappers, in Dark Mode it's white, so it emerge on the dark background.

                                       

                                      These two settings into info.plist turn off the initial statusBar and don’t turn it on later:

                                      UIStatusBarHidden (Status bar is initially hidden) YES
                                      UIViewControllerBasedStatusBarAppearance (View controller-based status bar appearance) NO

                                      (from h ttps://stackoverflow.com/questions/18979837/how-to-hide-ios-status-bar/18980833#18980833)

                                      Thank you Claude for your patiently support.