I am currently spinning a complex web of UIAppearance
modifiers*, and have come across a problem.
My usage of FlatUIKit's custom UIBarButton
appearance protocol is causing MFMailComposerViewController
to complain and stop working.
Therefore, instead of using UIAppearance
's whenContainedIn
method to specify classes that cause modification to occur, is there a way to exclude certain classes, i.e. a "when not contained in"?
*I am talking about the UIAppearance
protocol that is used to predefine object appearance settings in the app's delegate.
You can use appearanceWhenContainedIn:
to specify nil modification, which will give the default appearance:
[[UIBarButton appearance] setBarTintColor:[UIColor redColor]];
[[UIBarButton appearanceWhenContainedIn:[MFMailComposerViewController class], nil] setBarTintColor:nil];
As of iOS 9 SDK, there is also
[[UIBarButton appearance] setBarTintColor:[UIColor redColor]];
[[UIBarButton appearanceWhenContainedInInstancesOfClasses:@[[MFMailComposerViewController class]] setBarTintColor:nil];
Which can be used Swift-2 like so:
UIBarButton.appearance().barTintColor = UIColor.redColor()
UIBarButton.appearanceWhenContainedInInstancesOfClasses([MFMailComposerViewController.self]).barTintColor = nil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With