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

发布于 2024-09-04 14:36:32 字数 547 浏览 1 评论 0原文

我的所有视图都有一个蓝色导航栏,但是当我希望用户选择照片时,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];

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 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];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烛影斜 2024-09-11 14:36:32

另一种方法是使用

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

UINavigationControllerDelegate 协议的 istance 方法。

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

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.

天煞孤星 2024-09-11 14:36:32

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

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

UINavigationBar 色调颜色

UI颜色参考

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

初相遇 2024-09-11 14:36:32

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

using the delegate to change it worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文