隐藏电池栏共有三种方式:
1:用代码设置
在UIControl里面设置
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
- (BOOL)prefersStatusBarHidden{
return YES;//隐藏为YES,显示为NO
}
2:plist里面设置
先设置key:Status bar is initially hidden为YES
然后设置key:View controller-based status bar appearance为NO
完成,这个是全局设置
3:plist与代码一块进行设置
先在plist文件中,加入View controller-based status bar appearance项,并设置为NO;
//隐藏电池栏
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//此方法设置YES为隐藏,No为显示 ios7以后的方法
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
修改电池栏颜色
1.状态栏的两种形式----白底黑字和黑底白字(UIStatusBarStyleLightContent,UIStatusBarStyleDefault)
先在plist文件中,加入View controller-based status bar appearance项,并设置为NO;
2.要改变的VC中添加代码:
- (void) viewDidAppear:(BOOL)animated{ //黑底白字
[[UIApplicationsharedApplication]setStatusBarStyle:UIStatusBarStyleLightContentanimated:NO];
}
- (void) viewDidAppear:(BOOL)animated{
//白底黑字[UIApplicationsharedApplication]setStatusBarStyle:UIStatusBarStyleDefaultanimated:NO];
}