1

I have a UITabBarController with more than 5 UIViewControllers. I have set the value in my info.plist I have set the value for ViewController based status bar appearance to YES.

enter image description here

All of the UIViewControllers have the values

UIApplication.shared.statusBarUIView?.backgroundColor = customColor
self.setNeedsStatusBarAppearanceUpdate()

in viewDidLoad with customColor being a dark shade of blue. I'm also overriding the preferredStatusBarStyle variable to light content.

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

All UIViewControllers display the lightContent status bar. I have tried the same in the MoreTabBarController class but it doesn't work. I'm assuming the reason is because it isn't a UIViewController but rather a UITabBarController.

enter image description here

How do I change the Status bar color to light content in the MoreTabBarController?

Abhinandan Pratap
  • 2,142
  • 1
  • 18
  • 39
GIJoeCodes
  • 1,680
  • 1
  • 25
  • 28

2 Answers2

0

Use UIApplication.shared.statusBarStyle = .lightContent in didFinishLaunchingWithOptions and then use View controller-based status bar appearance key and set No for its boolean value in .info plist. Its change Status bar color to light content.

Amit gupta
  • 553
  • 3
  • 10
0

Open project settings option you can change status bar's style:

enter image description here

Next, go back to the Storyboard, Select the ViewController and in the Editor menu Select Embedin NavigationController. Select the Navigation Bar and in the Attribute Inspector set the Bar Tint color to red. Build and Run the project, The content of the status bar is dark again, which is the default. The reason for this is, iOS asked for the style of the status bar of the navigation controller instead of the contained ViewController. To change the style of all navigation controller inside the app, change the following method in the AppDelegate.swift file.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    UINavigationBar.appearance().barStyle = .blackOpaque
    return true
    }
Abhinandan Pratap
  • 2,142
  • 1
  • 18
  • 39