开发者

Change UIImagePicker Navigation Bar style to blue

All of my view has a blue navigation bar but when I want user to choose a photo, the UIImagePicker is black. I tried to set the navigation bar of UIImagePickerController to blue using UIBarStyleDefault but it does not work for me, the color is still black. I tried with other UIBarStyle like UIBarStyleBlack and UIBarStyleOpaque as well but it doesn't change the navigation bar of the picker anyway. Here is my code

    // Let th开发者_StackOverflow中文版e user choose a new photo.
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.navigationBar.barStyle = UIBarStyleDefault;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];


Another way is using

- (void)navigationController:(UINavigationController *)navigationController 
  willShowViewController:(UIViewController *)viewController
                animated:(BOOL)animated {
navigationController.navigationBar.barStyle = UIBarStyleDefault;
}

that is an istance method of the UINavigationControllerDelegate protocol.

This will change the navigation bar style to blue.


I think there is no way to change it. So my solution is using Color Meter to get the color of the default navigation bar in color code: red code, blue code, green code. Then I use the method

imagePicker.navigationBar.tintColor = [UIColor colorWithRed:redCode green:greenCode blue:blueCode alpha:0.1];

UINavigationBar tintColor

UIColor Reference


using the delegate to change it worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜