iOS7.0以后状态栏样式设置及隐藏
2018-02-09 本文已影响14人
朝辉
1.在Xcode info.plist中设置
![](https://img.haomeiwen.com/i1535093/0974df8d277b9f7e.png)
2.在viewContent中重写系统方法
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
return NO;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation
{
return UIStatusBarAnimationFade;
}
3.如果- (UIStatusBarStyle)preferredStatusBarStyle没有调用是因为viewContent存在导航控制器需要在导航控制器中实现- (UIStatusBarStyle)preferredStatusBarStyle如下
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
如果还是存在不调用的情况就在- (void)viewDidAppear:(BOOL)animated中主动调用
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
{
[self preferredStatusBarStyle];
}
}