状态栏上的时间、电池指示器和Wi-Fi信号显示为暗色。在这里还要注意的是,状态栏是分前景和背景两部分的。所谓的前景部分指的就是显示电池、时间等部分;背景部分就是现实白色或者图片的背景部分;那么在实际开发过程中,就需要我们根据不同的controller来修改我们的状态栏的风格
- 第一种情况
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent; // Light content, for use on dark backgrounds
}
- (BOOL)prefersStatusBarHidden
{
return YES; // 是否隐藏状态栏
}
- 第二种情况
(1)在project target的Info.plist中,插入一个新的key,名字为View controller-based status bar appearance,并将其值设置为NO。
![](https://img.haomeiwen.com/i1320373/310da4d51a703b15.jpeg)
#######(2) 接下来使用如下代码
- (void)initializeStatusBarWithApplication:(UIApplication *)application
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
application.statusBarStyle = UIStatusBarStyleLightContent; // Light content, for use on dark backgrounds
} else {
application.statusBarStyle = UIStatusBarStyleDefault; // Dark content, for use on light backgrounds
}
application.statusBarHidden = NO; // 是否隐藏状态栏
}
![](https://img.haomeiwen.com/i1320373/c7d2b5f15536c7c7.jpeg)
网友评论