【问题标题】:Change UIImagePicker Navigation Bar style to blue将 UIImagePicker 导航栏样式更改为蓝色
【发布时间】:2010-06-04 09:00: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];

【问题讨论】:

    标签: iphone objective-c uiimagepickercontroller


    【解决方案1】:

    另一种方法是使用

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

    那是UINavigationControllerDelegate protocol的一个实例方法。

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

    【讨论】:

      【解决方案2】:

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

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

      UINavigationBar tintColor

      UIColor Reference

      【讨论】:

      • @iOS7 会改变字体。
      【解决方案3】:

      使用委托来改变它对我有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-27
        • 1970-01-01
        • 1970-01-01
        • 2022-01-25
        • 2018-02-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多