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:As of iOS 9 SDK, there is also
Which can be used Swift-2 like so:
For me I used this one which works in iOS 10,
My solution is to create a custom subclass of all the container view controllers that are being used in the app as the main
UIWindow
subviews (window's root view controller or presented view controllers), such asUINavigationController
,UITabBarController
orUISplitViewController
.Let's say the app is only using
UINavigationController
. Create a subclass:Then use the
CustomizedNavigationController
instead of plainUINavigationController
everywhere in the app.Also, instead of specifying the appearance for every
UIBarButton
, specify the appearance only when contained in the subclass:Because
MFMailComposerViewController
is not using the subclass, it won't get customized.