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

时间:2010-06-04 09:00:16

标签: 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];

3 个答案:

答案 0 :(得分:7)

另一种方法是使用

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

这是UINavigationControllerDelegate protocol的实例方法。

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

答案 1 :(得分:3)

我认为没有办法改变它。所以我的解决方案是使用Color Meter以颜色代码获取默认导航栏的颜色:红色代码,蓝色代码,绿色代码。然后我使用方法

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

UINavigationBar tintColor

UIColor Reference

答案 2 :(得分:0)

使用委托更改它对我有用。

相关问题