0

我已经做了sublass从UINavigationController ......这里面I类设置的外观如下:套装的外观恢复为默认

UIImage *navBackgroundImage = [UIImage imageNamed:@"nav_bg"]; 
    [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault]; 

    [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: 
                  [UIColor whiteColor], UITextAttributeTextColor, 
                  [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor, 
                  [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], 
                  UITextAttributeTextShadowOffset, 
                  [UIFont fontWithName:@"Yellowtail" size:30.0], UITextAttributeFont, 
                  [UIColor whiteColor], UITextAttributeTextColor, nil]]; 
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0f green:170/255.0f blue:130/255.0f alpha:1.0f]]; 

    [[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:0.0f green:170/255.0f blue:130/255.0f alpha:1.0f]]; 
    [[UITabBar appearance] setBackgroundColor:[UIColor whiteColor]]; 

现在,在我的应用程序时,我想拍照就呈现我的UIImagePicker,但导航栏有像我的自定义导航控制器的导航栏相同的外观和取消按钮不起作用...

所以我的问题:我如何使用默认的iOS风格的图像选择器和其余的我的自定义样式?

回答

1

的研究小时后我已经解决了这个问题......解决方案很简单:

UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
picker.delegate = self; 

/* reset the style to the default one */ 
[picker.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 
[picker.navigationBar setTitleTextAttributes:nil]; 
[picker.navigationBar setBarTintColor:nil]; 

[self presentViewController:picker animated:YES completion:nil]; 

这里有人有同样的问题:Custom nav bar with UIImagePickerControl

0

由于你的答案最早出现在谷歌的时候我搜索这个问题,我更喜欢张贴正确的答案,而不是接受的答案。

This SO post正确处理问题。 UIAppearance具有用于精细UI定制的方法:appearanceWhenContainedIn:

如,例如:

[[UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil] setBackButtonBackgroundImage:[UIImage imageNamed:@"blank-button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];