代码之家  ›  专栏  ›  技术社区  ›  vodkhang

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

  •  0
  • vodkhang  · 技术社区  · 15 年前

    我的所有视图都有一个蓝色的导航栏,但是当我希望用户选择照片时,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 回复  |  直到 14 年前
        1
  •  7
  •   Sefran2    14 年前

    另一种方法是使用

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

    这是 UINavigationControllerDelegate protocol .

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

        2
  •  3
  •   vodkhang    15 年前

    我想没办法改变它。因此,我的解决方案是使用颜色计来获取颜色代码中默认导航栏的颜色:红色代码、蓝色代码、绿色代码。然后我用这个方法

    imagePicker.NavigationBar.Tintcolor=[uicolor colorWithRed:Redcode Green:Greencode Blue:BlueCode Alpha:0.1];

    UINavigationBar tintColor

    UIColor Reference

        3
  •  0
  •   Humberto    14 年前

    使用代理来更改它对我很有用。