iOS之后想要操作顶部状态栏就不是太容易了,操作步骤如下:
首先在info.plist文件中添加View controller-based status bar appearance项,
一. View controller-based status bar appearance项设为YES,则View controller对status bar的设置优先级高于application的设置。
这时 view controller中对status bar的设置优先级高于application的设置,用下面的方式隐藏status bar:
1、在view controller中调用setNeedsStatusBarAppearanceUpdate,更新status bar的显示。
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
}
2、覆盖view controller的prefersStatusBarHidden的实现,返会YES。 - (BOOL)prefersStatusBarHidden
{
return YES;
}
二. View controller-based status bar appearance项设为NO,则以application的设置为准,view controller的prefersStatusBarHidden方法无效,是根本不会被调用的。
1、用[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];的方法隐藏状态栏。
因为要兼容多个系统版本,我一般使用 方法二
北京折叠(一)http://www.jianshu.com/p/b4126f96e970
北京折叠(二)http://www.jianshu.com/p/da9e2745a50b
北京折叠(三)http://www.jianshu.com/p/7236ce2cab8c
北京折叠(四)http://www.jianshu.com/p/ad1439f8d75d
北京折叠(五)http://www.jianshu.com/p/1cb4eb82790e
趣借-全球好物借玩,微信号: qujiex,官网地址: http://qujiex.com
微信扫描以下二维码,关注“笑的抽筋”,每日获取搞笑视频,欢乐每一天。

网友评论