Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent UIImagePickerController change statusbar style?

UIImagePickerController changes statusbar style to black/opaque. I want to keep status-bar style black/translucent. I'm finding a way to prevent status bar style changing. Or making it transited smoothly. Now, presenting UIImagePickerController changes status-bar style instantly, even -[presentModalViewController:picker animated:YES] specified.

Any method, welcome, including hacking or private method. This is an app for AppStore, however I want to even try.

like image 696
eonil Avatar asked Jun 05 '10 21:06

eonil


2 Answers

I wanted the status bar to remain black opaque while showing the photo library picker (the photo picker changes it to black translucent) and this solved the issue for me.

Set the UIImagePickerDelegate:

libraryUI.delegate = self;

Implement the following callback:

- (void)navigationController:(UINavigationController *)navigationController 
      willShowViewController:(UIViewController *)viewController 
                    animated:(BOOL)animated {

    if ([navigationController isKindOfClass:[UIImagePickerController class]] && 
        ((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
    }
}

You can specify any kind of status bar style in here. In your case, you would probably have to remove the sourceType check and specify UIStatusBarStyleBlackTranslucent.

like image 100
Matej Bukovinski Avatar answered Sep 22 '22 00:09

Matej Bukovinski


Try this working perfectly on ios 8

-(void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated
{
    [[[viewController navigationController] navigationBar] setBarStyle:UIBarStyleBlack];
}
like image 32
Shoaib Avatar answered Sep 25 '22 00:09

Shoaib