Instance Method


Executes custom code using the traits of the current trait collection.


func performAsCurrent(_ actions: () -> Void)



A block containing the code you want to execute. This block has no return value and takes no parameters.


Use this method when you want to execute code using a set of traits that differ from those in the current trait environment. For example, you might use this method to draw part of a view's content with a different set of traits. This method temporarily replaces the traits of the current environment with the ones found in the current UITraitCollection. After the actions block finishes, the method restores the original traits to the environment.

You can call this method from any thread of your app.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software