<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "swift: -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIColor/init(named:inBundle:compatibleWithTraitCollection:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIColor(cm)colorNamed:inBundle:compatibleWithTraitCollection:::SYNTHESIZED::c:objc(cs)UIColor"
  },
  "title" : "init(named:inBundle:compatibleWithTraitCollection:)"
}
-->

# init(named:inBundle:compatibleWithTraitCollection:)

Creates a color object using the named asset that’s compatible with the specified trait collection.

```
init?(named name: String, inBundle bundle: Bundle?, compatibleWithTraitCollection traitCollection: UITraitCollection?)
```

## Parameters

`name`

The name of the asset containing the color.

`bundle`

The bundle containing the asset.

`traitCollection`

The trait collection that specifies the gamut to use when selecting the color.

## Return Value

An initialized color object. The returned object uses the color space specified for the asset.

## Discussion

---

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)