-1

I add Navigation Controller(2nd View) and add one UIViewController(3rd View) as root view controller.
And then I connect segue to Navigation Controller(2nd View) from anther UIViewController(1st View).
So I can see navigation Bar with Status bar space when the view is presented.
But the information like Carriers, batteries, time information are not shown in Status Bar. (I changed navigation Color to pink for showing you the problem.
The blue part is title view for navigation bar.)

enter image description here

So I tried 2 solutions.

First, I thought StatusBar Color problem. But it was not.

  UIApplication.shared.statusBarStyle = .default

Second, I tried following code for showing. It was not also.

override var prefersStatusBarHidden: Bool {
    return false

}

and

UIApplication.shared.setStatusBarHidden(false, with: UIStatusBarAnimation.none)

I need to solve this not-showing problem with status Bar.
I can see status Bar space but not information.

kimpro
  • 107
  • 1
  • 2
  • 10

2 Answers2

0

There are lots of ways to toggle the color and visibility of the status bar in iOS.

Similar question with possible correct answers for you:

How to change Status Bar text color in iOS 7

In short, if you want to toggle it between every screens, follow these steps:

  1. In your info.plist, add this new key:

View controller-based status bar appearance and value should be NO.

  1. In your viewWillAppear, toggle the status bar with the code you have posted:

UIApplication.shared.statusBarStyle = .lightContent - white or UIApplication.shared.statusBarStyle = .default - black

Edit: Initial ViewController --> Present Modally --> NavigationController + ViewController.

This is how you set up your screens, right?. If so,

  • You can setup the status bar in your NavigationController properties in your Interface Builder.
  • And toggle the visibility and/or color of your status bar in side the viewWillAppear of your 3rd ViewController.
Community
  • 1
  • 1
Glenn Posadas
  • 10,706
  • 4
  • 36
  • 75
0

I suggest you check out Debug View Hierarchy.

Based on my experiences in previous projects, if I can't come up with code-based solutions on UI-related problems the simplest debugging technique that I can do is check the view hierarchy during run time.

See if the Navigation Controller View blocks the Main View which can possibly hide the status bar and if yes, work your way on solving it.

I hope it helps.

Aleic
  • 1
  • 2