UIAppearance的"未包含在内"

Sar*_*eph 12 objective-c uikit ios uiappearance

我目前正在编制一个复杂的UIAppearance修饰符网络*,并遇到了一个问题.

我对FlatUIKit的自定义UIBarButton外观协议的使用导致MFMailComposerViewController抱怨和停止工作.

因此,有没有一种方法可以排除某些类,而不是使用UIAppearance's whenContainedIn方法来指定导致修改的类,即"何时不包含"?

*我在谈论UIAppearance用于在应用程序委托中预定义对象外观设置的协议.

Leo*_*ica 14

您可以使用appearanceWhenContainedIn:指定nil修改,这将提供默认外观:

[[UIBarButton appearance] setBarTintColor:[UIColor redColor]];
[[UIBarButton appearanceWhenContainedIn:[MFMailComposerViewController class], nil] setBarTintColor:nil];
Run Code Online (Sandbox Code Playgroud)

从iOS 9 SDK开始,也有

[[UIBarButton appearance] setBarTintColor:[UIColor redColor]];
[[UIBarButton appearanceWhenContainedInInstancesOfClasses:@[[MFMailComposerViewController class]] setBarTintColor:nil];
Run Code Online (Sandbox Code Playgroud)

哪个可以像Swift-2一样使用:

UIBarButton.appearance().barTintColor = UIColor.redColor()
UIBarButton.appearanceWhenContainedInInstancesOfClasses([MFMailComposerViewController.self]).barTintColor = nil
Run Code Online (Sandbox Code Playgroud)