Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIStatusBar appear in black in UITabBarViewController ios11

The issue is simple :

  • The Application is based on UITabBarViewController
  • 3 Tabs in the controllers
  • TabBar Views are configured in viewDidLoad for the UITabBarViewController

On launch, the UIStatusBar appear in Black background color Launch Status Bar

Changing to any tab the UIStatusBar get colored!

Correct Status Bar

What I'm missing?

like image 407
OXXY Avatar asked Oct 15 '17 20:10

OXXY


1 Answers

I had a similar issue some months ago - I solved it by adding the following lines into my AppDelegate. Please find below my swift code, I'm sure you know the objective-c syntax:

    // Setup general NavBar appearance
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
    UINavigationBar.appearance().isTranslucent = true
    UINavigationBar.appearance().tintColor = UIColor.white
    UIApplication.shared.statusBarStyle = .lightContent // => this would be the solution

I think the last line of code would be interesting for you. It's important to set this changes in your AppDelegate.

like image 68
AlexWoe89 Avatar answered Nov 15 '22 14:11

AlexWoe89