美文网首页iOS
UIImagePickerController偷换statusB

UIImagePickerController偷换statusB

作者: 千煌89 | 来源:发表于2014-11-24 11:24 被阅读856次

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


    显然是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];
        }
    }
    

    效果如下:

    修复后

    相关文章

      网友评论

      • c57dddf3b833:let pk = UIImagePickerController()
        pk.navigationBar.tintColor = .white
        pk.navigationBar.barStyle = .black

      本文标题:UIImagePickerController偷换statusB

      本文链接:https://www.haomeiwen.com/subject/hcywtttx.html