<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIColor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIColor"
  },
  "title" : "UIColor"
}
-->

# UIColor

An object that stores color data and sometimes opacity.

```
class UIColor
```

## Overview

Use color to customize your app’s appearance, communicate status, and help people visualize data. To learn more about using color in your apps, see [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/foundations/color/).

[`UIColor`](/documentation/UIKit/UIColor) provides a list of class properties that create adaptable and fixed colors such as blue, green, purple, and more. [`UIColor`](/documentation/UIKit/UIColor) also offers properties to specify system-provided colors for UI elements such as labels, text, and buttons. You can create color objects by specifying color component values such as RGB, hue, and saturation. You can also create colors from other color objects and even create a pattern-based color from an image.

> Important:
> Most developers have no need to subclass ``doc://com.apple.uikit/documentation/UIKit/UIColor``. The only time subclassing might be necessary is if you require support for additional color spaces or color models. If you do subclass, the properties and methods you add must be safe to use from multiple threads.

## Topics

### Getting existing colors

[UI element colors](/documentation/UIKit/ui-element-colors)

Choose colors for UI elements such as labels, text, backgrounds, and links.

[Standard colors](/documentation/UIKit/standard-colors)

Define standard color objects for specific shades, such as red, blue, green, black, white, and more.

[Color creation](/documentation/UIKit/color-creation)

Load colors from asset catalogs and create colors from raw component values.

### Applying the color to the drawing environment

[Customizing drawings](/documentation/UIKit/customizing-drawings)

Create custom colors and patterns for drawing in your app.

[`set()`](/documentation/UIKit/UIColor/set())

Sets the color of subsequent stroke and fill operations to the color that the receiver represents.

[`setFill()`](/documentation/UIKit/UIColor/setFill())

Sets the color of subsequent fill operations to the color that the receiver represents.

[`setStroke()`](/documentation/UIKit/UIColor/setStroke())

Sets the color of subsequent stroke operations to the color that the receiver represents.

### Getting the color information

[Determining color values with color spaces](/documentation/UIKit/determining-color-values-with-color-spaces)

Change the system’s interpretation of a color value for display by selecting a color space.

[`cgColor`](/documentation/UIKit/UIColor/cgColor)

The Quartz color that corresponds to the color object.

[`ciColor`](/documentation/UIKit/UIColor/ciColor)

The Core Image color that corresponds to the color object.

[`getHue(_:saturation:brightness:alpha:)`](/documentation/UIKit/UIColor/getHue(_:saturation:brightness:alpha:))

Returns the components that form the color in the HSB color space.

[`getRed(_:green:blue:alpha:)`](/documentation/UIKit/UIColor/getRed(_:green:blue:alpha:))

Returns the components that form the color in the RGB color space.

[`getWhite(_:alpha:)`](/documentation/UIKit/UIColor/getWhite(_:alpha:))

Returns the grayscale components of the color.

[`linearExposure`](/documentation/UIKit/UIColor/linearExposure)

The linear brightness multiplier that was applied when generating this color. Colors created with an exposure by UIColor create CGColors that are tagged with a contentHeadroom value. While CGColors created without a contentHeadroom tag will return 0 from CGColorGetHeadroom, UIColors generated in a similar fashion return a linearExposure of 1.0.

[`accessibilityName`](/documentation/UIKit/UIColor/accessibilityName)

A localized description of the color for accessibility attributes.

### Resolving a dynamically generated color

[`resolvedColor(with:)`](/documentation/UIKit/UIColor/resolvedColor(with:))

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

### Working with color prominence

[`prominence`](/documentation/UIKit/UIColor/prominence-swift.property)

[`withProminence(_:)`](/documentation/UIKit/UIColor/withProminence(_:))

Returns the version of the current color that results from applying the specified prominence.

[`UIColor.Prominence`](/documentation/UIKit/UIColor/Prominence-swift.enum)

A type that indicates the prominence of a color in the interface.

### Working with high dynamic range (HDR) colors

[`applyingContentHeadroom(_:)`](/documentation/UIKit/UIColor/applyingContentHeadroom(_:))

Reinterpret the color by applying a new `contentHeadroom` without changing the color components. Changing the `contentHeadroom` redefines the color relative to a different peak white, changing its behavior under tone mapping and the result of calling `standardDynamicRangeColor`. The new color will have a `contentHeadroom` >= 1.0.

[`standardDynamicRange`](/documentation/UIKit/UIColor/standardDynamicRange)

In some cases it is useful to recover the color that was base SDR color that was exposed to generate the given HDR color. If a color’s `linearExposure` is >1, then this will return the base SDR color.



---

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)