appearance(for:whenContainedInInstancesOf:)
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
static func appearance(for trait: UITraitCollection, whenContainedInInstancesOf containerTypes: [any UIAppearanceContainer.Type]) -> SelfParameters
- trait:
The trait collection to use for matching.
- containerTypes:
An array of appearance container classes, in ascending hierarchical order.
Return Value
The appearance proxy to use for the object.
Discussion
Set the containerTypes array to an ascending hierarchical list of containing types for the trait collection. For example, if you want a navigation bar to take on a specific appearance when contained in a navigation controller inside a tab bar controller, set containerTypes to [UINavigationController.self, UITabBarController.self] (Swift) or @[[UINavigationController class], [UITabBarController class]] (Objective-C).
Do not set containerTypes to an unrelated list of types or to a list that does not match the containment hierarchy of your user interface.