<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIColor/resolvedColor(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIColor(im)resolvedColorWithTraitCollection:"
  },
  "title" : "resolvedColor(with:)"
}
-->

# resolvedColor(with:)

Returns the version of the current color that results from the specified traits.

```
func resolvedColor(with traitCollection: UITraitCollection) -> UIColor
```

## Parameters

`traitCollection`

The traits to use when resolving the color information.

## Return Value

The version of the color to display for the specified traits.

## Discussion

Use this method when you need to resolve a dynamic color to a specific color value for the specified trait collection. For example, reading the [`cgColor`](/documentation/UIKit/UIColor/cgColor) property or calling [`getRed(_:green:blue:alpha:)`](/documentation/UIKit/UIColor/getRed(_:green:blue:alpha:)) resolves a dynamic color to a specific color value that’s no longer dynamic. If your calling context isn’t inside one of the methods documented in the [`current`](/documentation/UIKit/UITraitCollection/current) property, you need to provide a trait collection from an appropriate trait environment, such as your view or view controller.

The example below uses this method set a border color on a <doc://com.apple.documentation/documentation/QuartzCore/CALayer>:

```swift
// This method sets the border color when UITraitCollection.current is undefined.
func updateBorderColor(layer: CALayer) {
    
    // Read the trait collection from the view.
    let traitCollection = view.traitCollection
    // Use the trait collection to resolve a dynamic color.
    let borderColor = UIColor.label.resolvedColor(with: traitCollection)
    // Use the CGColor value of the resolved color.
    layer.borderColor = borderColor.cgColor
}
```

## See Also

[`performAsCurrent(_:)`](/documentation/UIKit/UITraitCollection/performAsCurrent(_:))

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)