我有一個UIPickerView
在UINavigationController
的子類內的視圖。我有一個UIAppearance
代理,我想要應用於包含在UINavigationController
子類中的許多視圖,但我不希望UIAppearance
在UIPickerView
上運行。從UIAppearancearance保護類
有沒有辦法讓UIAppearance
代理適用於UINavigationController
子類中的所有視圖,然後保護特定對象內的視圖不受其影響?
沒有UIAppearance,屏幕看起來是這樣的:
有了這個代碼:
#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;
}
屏幕看起來是這樣的:
我不不想要子視圖的UIPickerview被青色破壞,儘管我可能希望將青色應用於包含在UINavigationController中的許多其他視圖。
但是,UIPickerView也包含在UINavigationController中,所以它獲得了UIAppearance以及其他視圖。 –
附上截圖,我有點困惑,你的意思是,你不能通過外觀代理自定義選擇器視圖 – Vikings
我更新了原始帖子以包含代碼和截圖。 –