-
Notifications
You must be signed in to change notification settings - Fork 332
Status Bar
Grigorii Lutkov edited this page Apr 19, 2021
·
1 revision
If you want to have different status bar styles for root, left and right views, then you need to override prefersStatusBarHidden
, preferredStatusBarStyle
and preferredStatusBarUpdateAnimation
in corresponding view controller or instead you can use these properties:
rootViewStatusBarHidden: BOOL
rootViewStatusBarStyle: UIStatusBarStyle
rootViewStatusBarUpdateAnimation: UIStatusBarAnimation
leftViewStatusBarHidden: BOOL
leftViewStatusBarStyle: UIStatusBarStyle
leftViewStatusBarUpdateAnimation: UIStatusBarAnimation
rightViewStatusBarHidden: BOOL
rightViewStatusBarStyle: UIStatusBarStyle
rightViewStatusBarUpdateAnimation: UIStatusBarAnimation
These properties have greater priority than overridden inside controllers prefersStatusBarHidden, preferredStatusBarStyle, preferredStatusBarUpdateAnimation
.
For example, you had sideMenuController with rootViewController, leftViewController and rightViewController. For rootViewController, you can override it's default methods or use sideMenuController's properties:
// In RootViewController.swift
override var prefersStatusBarHidden : Bool {
return false
}
override var preferredStatusBarStyle : UIStatusBarStyle {
return .default
}
override var preferredStatusBarUpdateAnimation : UIStatusBarAnimation {
return .none
}
// OR in SideMenuController.swift
isRootViewStatusBarHidden = false
rootViewStatusBarStyle = .default
rootViewStatusBarUpdateAnimation = .none
// OR in SideMenuController.swift
override var isRootViewStatusBarHidden: Bool {
get { return false }
set { super.isRootViewStatusBarHidden = newValue }
}
override var rootViewStatusBarStyle: UIStatusBarStyle {
get { return .default }
set { super.rootViewStatusBarStyle = newValue }
}
override var rootViewStatusBarUpdateAnimation: UIStatusBarAnimation {
get { return .none }
set { super.rootViewStatusBarUpdateAnimation = newValue }
}
For leftViewController and rightViewController
approach is the same.