标签:style class blog code color strong
info.plist文件中,View controller-based status bar appearance项设为YES,则View controller对status bar的设置优先级高于application的设置。为NO则以application的设置为准,view controller的prefersStatusBarHidden方法无效,是根本不会被调用的。
这时 view controller中对status bar的设置优先级高于application的设置,用下面的方式隐藏status bar。
1 - (void)viewDidAppear:(BOOL)animated 2 { 3 [super viewDidAppear:animated]; 4 5 if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { 6 [self prefersStatusBarHidden]; 7 [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 8 } 9 }
1 - (BOOL)prefersStatusBarHidden 2 { 3 return YES; 4 }
这时application的设置优先级最高,用下面的方式隐藏status bar:
1 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
1 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
如果是iOS6,则还通过sharedApplication隐藏。
如果是iOS7,则用setNeedsStatusBarAppearanceUpdate加prefersStatusBarHidden的方式来隐藏 status bar。
1 NSNumber *isVCBasedStatusBarAppearanceNum = [[NSBundle mainBundle]objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"]; 2 if (isVCBasedStatusBarAppearanceNum) { 3 _isVCBasedStatusBarAppearance = isVCBasedStatusBarAppearanceNum.boolValue; 4 } else { 5 _isVCBasedStatusBarAppearance = YES; // default 6 }
iOS7下隐藏status bar的详细研究,布布扣,bubuko.com
标签:style class blog code color strong
原文地址:http://www.cnblogs.com/machenglong/p/3795876.html