将UIImagePicker导航栏样式更改为蓝色

vod*_*ang 0 iphone objective-c uiimagepickercontroller

我的所有视图都有一个蓝色导航栏,但当我希望用户选择一张照片时,UIImagePicker是黑色的.我尝试使用UIBarStyleDefault将UIImagePickerController的导航栏设置为蓝色,但它对我不起作用,颜色仍为黑色.我尝试过其他UIBarStyle,如UIBarStyleBlack和UIBarStyleOpaque,但它不会改变选择器的导航栏.这是我的代码

    // Let the user choose a new photo.
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.navigationBar.barStyle = UIBarStyleDefault;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];
Run Code Online (Sandbox Code Playgroud)

Sef*_*an2 7

另一种方式是使用

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

这是UINavigationControllerDelegate协议的istance方法.

这会将导航栏样式更改为蓝色.