UITraitChangeObservable.TraitChangeHandler
A closure the system executes when observed traits change.
Declaration
typealias TraitChangeHandler<TraitEnvironment> = (TraitEnvironment, UITraitCollection) -> Void where TraitEnvironment : UITraitEnvironmentParameters
- traitEnvironment:
The observed object containing the updated trait collection.
- previousTraitCollection:
The trait collection prior to the changes that triggered the execution of the handler.
Discussion
Use registerForTraitChanges(_:handler:) to register a list of traits to observe and a handler to execute.
If the closure captures a strong reference to the object receiving the registration, it creates a strong reference cycle. Use the traitEnvironment parameter to refer to the observed object inside the closure.