---
title: "init(dynamicProvider:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uicolor/init(dynamicprovider:)"
---

# init(dynamicProvider:)

Creates a color object that uses the specified block to generate its color data dynamically.

## Declaration

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

## Parameters

- `dynamicProvider`: A block that determines the appropriate color values based on the specified traits. This block returns a doc://com.apple.uikit/documentation/UIKit/UIColor object and takes a single parameter:

## Return Value

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

## Discussion

Discussion 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.
