ios UIImagePickerController 导航栏透明

来源:互联网 发布:我知女人心配乐 编辑:程序博客网 时间:2024/05/21 19:45

当程序运行的ios7的手机中时,如果我们需要调用手机的相册获取图片,此时导航栏和状态栏显示为透明,解决方法为:



UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {        //判断当前设备的系统是否是ios7.0以上
    picker.edgesForExtendedLayout = UIRectEdgeNone;
}

[self presentViewController:picker animated:YES completion:nil];



然后在UIImagePickerController delegate 方法中添加代码

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated
{
    if ([navigationController isKindOfClass:[UIImagePickerController class]])
    {        
        viewController.navigationController.navigationBar.translucent = NO;
        viewController.edgesForExtendedLayout = UIRectEdgeNone;
    }
}



通过以上代码,即可以记解决ios7调用系统的相册时出现的导航栏透明的情况

0 0
原创粉丝点击