[iOS] iOS9及后续版本修改状态栏

首先设置 Info.plist 里 View controller-based status bar appearance 设置为 YES

1. 启动页状态栏

启动页状态栏设置

2. 其他页面状态栏

  • 先重写 UITabBarControllerchildForStatusBarStyle
    UINavigationControllerchildForStatusBarStyle
extension UITabBarController {
    open override var childForStatusBarStyle: UIViewController? {
        return selectedViewController?.childForStatusBarStyle ?? selectedViewController
    }
}

extension UINavigationController {
    open override var childForStatusBarStyle: UIViewController? {
        return topViewController?.childForStatusBarStyle ?? topViewController
    }
}
  • BaseVC 里重写 preferredStatusBarStyle
override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

你可能感兴趣的:([iOS] iOS9及后续版本修改状态栏)