Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 保护类不受外观的影响_Iphone_Ios_Uipickerview_Uiappearance - Fatal编程技术网

Iphone 保护类不受外观的影响

Iphone 保护类不受外观的影响,iphone,ios,uipickerview,uiappearance,Iphone,Ios,Uipickerview,Uiappearance,我在UINavigationController的子类中的视图中有一个UIPickerView。我有一个UIAppearance代理,我想将它应用于UINavigationController子类中包含的许多视图,但我不想UIAppearance对UIPickerView进行操作 有没有办法让UIAppearance代理应用于UINavigationController子类中的所有视图,然后保护特定对象中的视图不受其影响 如果没有UI外观,屏幕如下所示: 使用此代码: #import "App

我在
UINavigationController
的子类中的视图中有一个
UIPickerView
。我有一个
UIAppearance
代理,我想将它应用于
UINavigationController
子类中包含的许多视图,但我不想
UIAppearance
UIPickerView
进行操作

有没有办法让
UIAppearance
代理应用于
UINavigationController
子类中的所有视图,然后保护特定对象中的视图不受其影响

如果没有UI外观,屏幕如下所示:

使用此代码:

#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是一个视图,因此它的颜色会更改

编辑:

我认为,对于你真正想要的东西来说,仪容礼仪可能是矫枉过正了。您希望更改选择器视图后面的视图的颜色,然后继续设置其背景色

[[self YOUR_VIEW] setBackgroundColor:[UIColor blueColor]];
如果要将某个视图的所有部分都更改为特定颜色,则外观协议可以正常工作。例如,如果希望所有导航栏都是红色,可以在一个点中设置此选项,这样会更改应用程序中的所有导航栏


要实现这一点,您必须将所有视图子类化为蓝色,并在包含时使用外观协议方法AppearanceWhen进行设置。

但是,UIPickerView也包含在UINavigationController中,因此它将获得UIAppearance以及其他视图。请附上屏幕截图,我有点困惑,你的意思是,你不能通过外观定制选择器视图proxy@gary_z检查编辑,但您试图将什么更改为蓝色?仅包含UIPickerView的视图。但在实际操作中,可能会有按钮标签、导航栏标签等,我也希望将其更改为青色。我希望实现的是将任何视图按到UINavigationController上以获得青色,同时不破坏其所有子视图的背景。我想我要做的是为大视图创建一个UIView子类,并将外观应用于它们。