一 初始化
//方法一(代码设置):
现在ios7已经更改为透明,并且不占用屏幕高度。其中隐藏及显示的方法如下:
在uiviewcontroller的子类下,调用:
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
– (BOOL)prefersStatusBarHidden
{
return YES;//隐藏为YES,显示为NO
}
在视图切换,比如addsubview,present,pushin等,也需要注意及修改该状态栏。
//方法二(在plist里设置):
首先设置key:Status bar is initially hidden 为YES
然后设置key:View controller-based status bar appearance 为NO
即可实现全局隐藏状态栏了
二 打开相册后,状态栏出现的问题
方法一:加category
@implementation
UIImagePickerController (RemoveStatusBar)
- (
void
)viewDidLoad
{
[
super
viewDidLoad];
// not an issue before IOS7 (likely to be fixed after too...
if
(floor(
NSFoundationVersionNumber
) >
NSFoundationVersionNumber_iOS_6_1
)
{
self
.edgesForExtendedLayout = UIRectEdgeNone;
[
self
prefersStatusBarHidden];
[
self
performSelector:
@selector
(setNeedsStatusBarAppearanceUpdate)];
}
}
- (
BOOL
)prefersStatusBarHidden
{
return
YES
;
}
- (UIViewController *)childViewControllerForStatusBarHidden
{
return
nil
;
}
@end
你必须 登录后 才能对文章进行评论!