解决当把系统自带的UIImagePickerController 作为一个uiviewcontroller时有20像素间隙的问题

#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];

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值