I have a UIPickerView
in a view inside a subclass of UINavigationController
. I have a UIAppearance
proxy that I want to apply to many views contained in the UINavigationController
subclass, but I don't want the UIAppearance
to operate on the UIPickerView
.
Is there any way to have the UIAppearance
proxy apply to all views inside the UINavigationController
subclass and then protect views inside specific objects from its effect?
Without UIAppearance, the screen looks like this:
With this code:
#import "AppDelegate.h"
@interface AppDelegate()
@property (nonatomic, strong) UINavigationController *nvcMain ;
@end
@implementation AppDelegate
@synthesize window ;
@synthesize nvcMain ;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_ph" bundle:nil] ;
nvcMain = [sb instantiateInitialViewController] ;
window.rootViewController = nvcMain ;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
id apprNVCView = [UIView appearanceWhenContainedIn:[UINavigationController class], nil] ;
[apprNVCView setBackgroundColor:[UIColor cyanColor] ];
return YES;
}
the screen looks like this:
I don't want the subviews of the UIPickerview to be clobbered by the cyan, although I may want to apply cyan to many other views contained in the UINavigationController.
I'm not sure exactly what you are trying to accomplish, but here is what is happening with your code.
You are setting all the views background color to cyan inside the navigation controller. The UIPickerView is a view so, it's color is changed.
Edit:
I think the appearance protocol is probably just overkill for what you actually want. You want to change the color of a view behind the picker view, then just go ahead and set its background color.
[[self YOUR_VIEW] setBackgroundColor:[UIColor blueColor]];
The appearance protocol works well if you want to change all of a certain view to a particular color. For example, you want all your navigation bars to be a red color, you could set this in one spot, and it would change all navigation bars in the application.
For this to work, you would have to subclass all views you want to be that blue color, and set them with the appearance protocol method appearanceWhenContainedIn.