1. 9.0之前,改變狀態(tài)欄方式?
.plist 文件 設(shè)置?View controller-based status bar appearance = no; 不可以繼承全局狀態(tài)欄風(fēng)格,并重寫。
application.statusBarStyle = UIStatusBarStyleLightContent;?
// Setting the statusBarStyle does nothing if your application is using the default UIViewController-based status bar system.
@property(readwrite, nonatomic) UIStatusBarStyle statusBarStyle NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController preferredStatusBarStyle]") __TVOS_PROHIBITED;
2.9.0以后,可以通過(guò)?preferredStatusBarStyle 方式修改。
一 :首先設(shè)置.plist ?View controller-based status bar appearance = YES;
二:設(shè)計(jì)兩組改變方式:
1.(多個(gè))涉及是UINavigationController導(dǎo)航,動(dòng)態(tài)設(shè)置切換ViewController不同
2.(單個(gè))僅設(shè)計(jì)到某個(gè)ViewController變換
3.上述兩種情況又分切換類型:push,presentmodel等調(diào)用次序不同。
三:調(diào)用??[self setNeedsStatusBarAppearanceUpdate];
如果根導(dǎo)航是UINavigationController 不用在主動(dòng)調(diào)用,默認(rèn)調(diào)用該方法。

多個(gè):
// Override to return a child view controller or nil. If non-nil, that view controller's status bar appearance attributes will be used. If nil, self is used. Whenever the return values from these methods change, -setNeedsUpdatedStatusBarAttributes should be called.
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic,readonly,nullable)UIViewController*childViewControllerForStatusBarStyleNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
@property(nonatomic,readonly,nullable)UIViewController*childViewControllerForStatusBarHiddenNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
#else
- (nullableUIViewController *)childViewControllerForStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
- (nullableUIViewController *)childViewControllerForStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
#endif
1.雖然View controller-based status bar appearance = YES;但是全局狀態(tài)欄樣式由RootViewController樣式?jīng)Q定。
2.重寫或分類重寫上面方法
- (nullableUIViewController *)childViewControllerForStatusBarStyle
- (nullableUIViewController *)childViewControllerForStatusBarHidden?

業(yè)務(wù)決定某個(gè)控制器狀態(tài)欄重寫一個(gè)或兩個(gè)方式:
- (UIStatusBarStyle)preferredStatusBarStyle
- (BOOL)prefersStatusBarHidden?
單個(gè)情況:
/* The preferredContentSize is used for any container laying out a child view controller.
?*/
@property(nonatomic)CGSizepreferredContentSizeNS_AVAILABLE_IOS(7_0);
// These methods control the attributes of the status bar when this view controller is shown. They can be overridden in view controller subclasses to return the desired status bar attributes.
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) UIStatusBarStyle preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault
@property(nonatomic,readonly)BOOLprefersStatusBarHiddenNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;// Defaults to NO
// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.
@property(nonatomic,readonly)UIStatusBarAnimationpreferredStatusBarUpdateAnimationNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;// Defaults to UIStatusBarAnimationFade
#else
- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;// Defaults to UIStatusBarStyleDefault
- (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;// Defaults to NO
// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;// Defaults to UIStatusBarAnimationFade
#endif
// This should be called whenever the return values for the view controller's status bar attributes have changed. If it is called from within an animation block, the changes will be animated along with the rest of the animation block.
- (void)setNeedsStatusBarAppearanceUpdateNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
1.主動(dòng)觸發(fā)
[self setNeedsStatusBarAppearanceUpdate];
2.業(yè)務(wù)決定某個(gè)控制器狀態(tài)欄重寫一個(gè)或兩個(gè)方式:
- (UIStatusBarStyle)preferredStatusBarStyle
- (BOOL)prefersStatusBarHidden?