Created by CyanHall.com
on 12/23/2020
, Last updated: 03/30/2021.
👉 Star me if it’s helpful.
👉 Star me if it’s helpful.
class ViewController: UIViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
// subclass UINavigationController is required if your ViewController is inside
class NavigationController: UINavigationController {
override var childViewControllerForStatusBarStyle: UIViewController? {
return visibleViewController
}
}
// subclass UITabBarController is required if your ViewController is inside
class TabBarController: UITabBarController {
override var childViewControllerForStatusBarStyle: UIViewController? {
return selectedViewController
}
}
// While using present, preferredStatusBarStyle problably won't work, add these:
vc.modalPresentationStyle = .overCurrentContext
vc.modalPresentationCapturesStatusBarAppearance = true
// Force preferredStatusBarStyle update if needed
self.setNeedsStatusBarAppearanceUpdate()
More