I have multiple UITabBar in my application and some ViewController has White color statusbar and some ViewController has black color statusbar.
My info.plist
View controller-based status bar appearance to YES
My Viewcontroller has below code.
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default //or return . lightContent
}
but preferredStatusBarStyle never getting called.
i have also written below line in my controller viewDidLoad but still above wasn't getting called.
self.setNeedsStatusBarAppearanceUpdate()
also i have changeed controller-based status bar appearance to YES && NO for multiple time to check but nothing helps to me.
I have also tried below solutions and other stackoverflow answers but nothing helps me.
preferredStatusBarStyle not respecting on iOS 13
preferredStatusBarStyle var not working in iOS12?
EDIT
I have tried below code which returns me the topViewController and it will call the preferredStatusBarStyle of that ViewController
extension UINavigationController {
override open var childForStatusBarStyle: UIViewController? {
return topViewController
}
}
so once the topViewController found it will call preferredStatusBarStyle of that particular ViewController.
but the issue is that it wasn't getting called inside UITabBarController -> UINavigationController -> UIViewController.
Requirment
I have 2 different TabBarController.
1st TabBarController statusBarStyle is .lightContent.
2nd TabBarController statusBarStyle is .lightContent and .default in different controller.
When i change to the 2nd TabBarController it will call preferredStatusBarStyle of 2nd TabBarController and all ViewController statusBarStyle goes .default but some of my controller statusBarStyle wants to be of .ligthContent
How can i achieve this?
any help will be appreciated.
Thanks