由 CyanHall.com
创建于 2020-12-23,
上次更新:2021-03-30。
👉 如果有用请点赞。
👉 如果有用请点赞。
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()
更多