Contents

appearanceForTraitCollection:whenContainedIn:

Returns the appearance proxy for the object when it’s contained in the hierarchy the specified classes describe and has the specified trait collection.

Declaration

+ (instancetype) appearanceForTraitCollection:(UITraitCollection *) trait whenContainedIn:(Class<UIAppearanceContainer> *) ContainerClass;

Parameters

  • trait:

    The trait collection to use for matching.

  • ContainerClass:

    A nil-terminated list of appearance container classes, in ascending hierarchical order.

Return Value

The appearance proxy to use for the object.

Discussion

Set the ContainerClass array to an ascending hierarchical list of types where the appearance settings should apply when the caller type is contained within them for the trait collection. For example, if you want a UINavigationBar to take on a specific appearance when contained in a UINavigationController inside a UITabBarController, set ContainerClass to @[[UINavigationController class], [UITabBarController class], nil].

Do not set ContainerClass to an unrelated list of types or to a list that does not match the containment hierarchy of your user interface.

This method throws an exception for any item in the var-args list that is not a Class object that conforms to the UIAppearanceContainer protocol.

See Also

Working with the appearance proxy