UIStatusBar appear in black in UITabBarViewController ios11 UIStatusBar appear in black in UITabBarViewController ios11 objective-c objective-c

UIStatusBar appear in black in UITabBarViewController ios11


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.


I had a similar issue. While not directly related the OP's issue with the tab bar, I too saw that my translucent status bar had appeared to turn opaque and was pushing the view down.

After migrating my project from Swift 3 with Xcode 8 to Swift 4 with Xcode 9, I started experiencing this same issue where the status bar appeared to be pushing content down when it was visible. At first I thought it was an issue with the preferred UIStatusBarStyle I had set (I was using UIStatusBarStyleLightContent), but that was working correctly.

The issue was that in the move from Xcode 8 to 9, a subview in one of my view controllers was misplaced in the Storyboard. A constraint that previously pinned that view to the top of the view controller was pointing incorrectly pointing to the View (with margins) instead of the Top Layout Guide. Switching this constraint to use the Top Layout Guide with a value of 0 solved my problem.

Storyboard


In didFinishLaunchingWithOptions method set status bar style to light content

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Override point for customization after application launch.[application setStatusBarStyle:UIStatusBarStyleLightContent];

and in every viewController return this :

-(UIStatusBarStyle)preferredStatusBarStyle{return UIStatusBarStyleLightContent;}

or if you are using the UINavigationController then also add this line of code in every viewController (or make a baseViewController) viewWillAppear method

- (void)viewWillAppear:(BOOL)animated{[super viewWillAppear:animated];self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;