将 UIImagePicker 导航栏样式更改为蓝色
我的所有视图都有一个蓝色导航栏,但是当我希望用户选择照片时,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种方法是使用
UINavigationControllerDelegate 协议的 istance 方法。
这会将导航栏样式更改为蓝色。
Another way is using
that is an istance method of the UINavigationControllerDelegate protocol.
This will change the navigation bar style to blue.
我认为没有办法改变它。所以我的解决方案是使用 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
使用委托来改变它对我有用。
using the delegate to change it worked for me.