#pragma mark --
#pragma mark Methods
- (void)initImagePickerControllerInterface
{
if (!_imagePickerController) {
_imagePickerController = [[UIImagePickerController alloc] init];
}
[_imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[_imagePickerController setDelegate:self];
[_imagePickerController setAllowsEditing:NO];
[self addChildViewController:_imagePickerController];
[self.view addSubview:_imagePickerController.view];
if ([GNDevice versionPermit:7 second:0]) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
} else {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
}
}
然后在delegate里写上
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if ([GNDevice versionPermit:7 second:0]) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
} else {
//其实就是加了这个动画
[UIView animateWithDuration:0.4 animations:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
} completion:^(BOOL finished) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}];
}
UIView *custom = [[UIView alloc] initWithFrame:CGRectMake(0,0,0,0)];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:custom];
[viewController.navigationItem setRightBarButtonItem:btn animated:NO];
viewController.title = @"扫 一 扫";
if ([GNDevice versionPermit:7 second:0]) { //下面这段话如果在IOS5上运行的话会显示有点问题,所以这个地方注释
NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],UITextAttributeTextColor,[UIFont boldSystemFontOfSize:20],UITextAttributeFont, nil];
[viewController.navigationController.navigationBar setTitleTextAttributes:attributes];
}
[btn release];
[custom release];
}