1、将单个页面的StatusBar文字颜色改为白色,动态更改也可以在这里设置
-(UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
2、将所有页面的StatusBar文字颜色改为白色
plist文件中View controller-based status bar appearance 设置为 NO
在这种情况下,将单个页面的文字颜色更改为黑色
-(void)viewWillAppear:(BOOL)animated { [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; }
3、scrollView滑动更改StatusBar的文字颜色
-(void)scrollViewDidScroll:(UIScrollView *)scrollView { _offsetY = scrollView.contentOffset.y; [self setNeedsStatusBarAppearanceUpdate]; //更新statusBar颜色,调用preferredStatusBarStyle } - (UIStatusBarStyle)preferredStatusBarStyle { if (_offsetY <= 136) { return UIStatusBarStyleLightContent; } return UIStatusBarStyleDefault; }