4

我想将 a 的条形样式设置UIImagePickerController如下,但条形仍然是UIBarStyleBlackTranslucent. 是否可以设置栏样式UIImagePickerController?提前致谢!

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;        
imagePicker.navigationBar.barStyle = UIBarStyleBlack;

编辑 1

我可以通过以下方式设置色调颜色:

imagePicker.navigationBar.tintColor = UIColorFromRGB(0xCC6600);
4

3 回答 3

6

这对我有用(您需要测试navigationController的类,而不是正在呈现的viewController,并且您似乎还需要设置不透明的背景颜色)

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated
{
    if ([navigationController isKindOfClass:[UIImagePickerController class]])
    {
        navigationController.navigationBar.barStyle = UIBarStyleBlack;
        navigationController.navigationBar.backgroundColor = [UIColor blackColor];
    }
}
于 2013-06-27T09:14:07.277 回答
1
imagePicker.navigationBar.tintColor=[UIColor blackColor];
于 2013-06-27T13:39:02.200 回答
0

您可以通过实现UINavigationControllerDelegate方法来进行更改navigationController:willShowViewController:,如下所示:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController
            animated:(BOOL)animated {
    if([viewController isKindOfClass:[UIImagePickerController class]])
             navigationController.navigationBar.barStyle = UIBarStyleBlack;
 }
于 2012-06-13T19:50:50.917 回答