一:統(tǒng)一設(shè)置狀態(tài)欄風格
>前提:在info.plist 中添加 View controller-based status bar appearance并設(shè)置為NO 意為:不基于單個控制器設(shè)置狀態(tài)欄風格
方法一:
TAGGETS->General->Deployment Info-> Status Bar Style 選擇Light(前景色為白色)Default(前景色為黑色 即默認)
方法二:
AppDelegate.m 中增加 application.statusBarStyle = UIStatusBarStyleLightContent
二:單獨設(shè)置每個控制器的狀態(tài)欄風格
>前提:在info.plist 中添加 View controller-based status bar appearance 并設(shè)置為YES 意為:基于單個控制器設(shè)置狀態(tài)欄風格
第一種情況:控制器在當前NavigationController中
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//設(shè)置狀態(tài)欄
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewDidAppear:animated];
//重置狀態(tài)欄
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
}
第二種情況:控制器不在當前NavigationController中
在控制器中重寫
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}