Set UIBarStyle of UIImagePickerController

I would like to set the bar style of a UIImagePickerController as following, but the bar is still UIBarStyleBlackTranslucent. Is it possible to set the bar style of UIImagePickerController? Thanks in advance!

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;        
imagePicker.navigationBar.barStyle = UIBarStyleBlack;

Edit 1

I can set the tint color through:

imagePicker.navigationBar.tintColor = UIColorFromRGB(0xCC6600);

Answers


Here's what worked for me (you need to test the class of the navigationController, not the viewController being presented, and you need to set a non-transparent background color as well it seems)

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated
{
    if ([navigationController isKindOfClass:[UIImagePickerController class]])
    {
        navigationController.navigationBar.barStyle = UIBarStyleBlack;
        navigationController.navigationBar.backgroundColor = [UIColor blackColor];
    }
}

imagePicker.navigationBar.tintColor=[UIColor blackColor];

You can make the change by implementing the UINavigationControllerDelegate method navigationController:willShowViewController:, like this:

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

Need Your Help

Why Laravel 4 CSRF token is not working?

laravel token csrf

I'm actually playing around with Laravel 4. Right now I'm implemented the CSRF token security on form post.

Initialize static member of template inner class

c++ templates static initialization

I have problem with the syntax needed to initialize a static member in a class template. Here is the code (I tried to reduce it as much as I could):