UIImagePickerController偷换statusBar颜色的问题

使用UIImagePickerController获取图库照片后,发现statusBar的颜色从白色变成了黑色,


UIImagePickerController偷换statusBar颜色的问题_第1张图片
UIImagePickerController偷换statusBar颜色的问题_第2张图片

显然是UIImagePickerController的navigationbar在作怪,在调用UIImagePickerController的地方,加上如下代码:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // bug fixes: UIIMagePickerController使用中偷换StatusBar颜色的问题
    if ([navigationController isKindOfClass:[UIImagePickerController class]] && ((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
    }
}

效果如下:

UIImagePickerController偷换statusBar颜色的问题_第3张图片
修复后

你可能感兴趣的:(UIImagePickerController偷换statusBar颜色的问题)