Creates a color object that generates its color data dynamically using the specified block.


init(dynamicProvider: @escaping (UITraitCollection) -> UIColor)



A block that determines the appropriate color values based on the specified traits. This block returns a UIColor object and takes a single parameter:


The trait collection to use when generating the color information. Always use the traits in this collection, and not the traits of the current environment, when determining the color information.

Return Value

A color object whose color information is provided by the specified block.


Use this method to create a color object whose component values change based on the currently active traits. The block you provide creates a new color object based on the traits in the provided trait collection.

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