标签:ios
直接上代码;对UIImagePickerController扩展:
// // UIImagePickerController+StatusBarHidden.m // // // Created by fangmi-huangchengda on 15/7/28. // // #import "UIImagePickerController+StatusBarHidden.h" #import <objc/runtime.h> @implementation UIImagePickerController (StatusBarHidden) - (void)viewDidLoad { [super viewDidLoad]; [self setHidetatusBar:YES]; [self performSelector:@selector(hideStatusBar) withObject:nil afterDelay:0.5]; } - (BOOL)prefersStatusBarHidden { if ([self hidetatusBar]) { BOOL hide = (self.sourceType== UIImagePickerControllerSourceTypeCamera)? YES : NO; return hide; } return NO; } - (UIViewController *)childViewControllerForStatusBarHidden { if ([self hidetatusBar]) { return nil; } return [self.childViewControllers lastObject]; } - (void)setHidetatusBar:(BOOL)hidetatusBar { objc_setAssociatedObject(self, (__bridge const void *)(@"hidetatusBar"), [NSNumber numberWithBool:hidetatusBar], OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -(BOOL)hidetatusBar { NSNumber *hidetatusBar = objc_getAssociatedObject(self, (__bridge const void *)(@"hidetatusBar")); return [hidetatusBar boolValue]; } - (void)hideStatusBar { [self setHidetatusBar:YES]; [self prefersStatusBarHidden]; if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; } } - (void)showStatusBar { [self setHidetatusBar:NO]; [self prefersStatusBarHidden]; if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; } } @end
版权声明:本文为博主原创文章,未经博主允许不得转载。
UIImagePickerController隐藏statusBar
标签:ios
原文地址:http://blog.csdn.net/isalvador/article/details/47107057