CGColor

A set of components that define a color, with a color space specifying how to interpret them.

Overview

Color objects provide a fast and convenient way to manage and set colors, especially colors that are used repeatedly. Drawing operations use color objects for setting fill and stroke colors, managing alpha, and setting color with a pattern.

Topics

Getting a Constant Color

CGColorGetConstantColor

Returns a color object that represents a constant color.

Retaining and Releasing Color Objects

CGColorRelease

Decrements the retain count of a color.

CGColorRetain

Increments the retain count of a color.

Creating Color Objects

CGColorCreate

Creates a color using a list of intensity values (including alpha) and an associated color space.

CGColorCreateCopy

Creates a copy of an existing color.

CGColorCreateGenericGray

Creates a color in the Generic gray color space.

CGColorCreateGenericRGB

Creates a color in the Generic RGB color space.

CGColorCreateSRGB

Creates a color in the sRGB color space.

Beta
CGColorCreateGenericCMYK

Creates a color in the Generic CMYK color space.

CGColorCreateCopyWithAlpha

Creates a copy of an existing color, substituting a new alpha value.

CGColorCreateWithPattern

Creates a color using a list of intensity values (including alpha), a pattern color space, and a pattern.

CGColorCreateCopyByMatchingToColorSpace

Creates a new color in a different color space that matches the provided color.

Getting Information about Core Graphics Colors

CGColorEqualToColor

Indicates whether two colors are equal.

CGColorGetAlpha

Returns the value of the alpha component associated with a color.

CGColorGetColorSpace

Returns the color space associated with a color.

CGColorGetComponents

Returns the values of the color components (including alpha) associated with a color.

CGColorGetNumberOfComponents

Returns the number of color components (including alpha) associated with a color.

CGColorGetPattern

Returns the pattern associated with a color in a pattern color space.

CGColorGetTypeID

Returns the Core Foundation type identifier for a color data type.

Data Types

CGColorRef

A set of components that define a color, with a color space specifying how to interpret them.

Constants

Constant Colors

Commonly used colors.

See Also

Opaque Types

CGBitmapContext

A type of CGContextRef that you can use for drawing bits to memory.

CGColorConversionInfo

An object that describes how to convert between color spaces for use by other system services.

CGColorSpace

A profile that specifies how to interpret a color value for display.

CGContext

A Quartz 2D drawing destination.

CGDataConsumer

An abstraction for data-writing tasks that eliminates the need to manage a raw memory buffer.

CGDataProvider

An abstraction for data-reading tasks that eliminates the need to manage a raw memory buffer.

CGFont

A set of character glyphs and layout information for drawing text.

CGFunction

A general facility for defining and using callback functions.

CGGLContext

Deprecated. A type of CGContextRef for drawing OpenGL content.

CGGradient

A definition for a smooth transition between colors for drawing radial and axial gradient fills.

CGImage

A bitmap image or image mask.

CGLayer

An offscreen context for reusing content drawn with Core Graphics.

CGPath

Immutable and mutable types for graphics paths: mathematical descriptions of shapes or lines to be drawn in a graphics context.

CGPattern

A 2D pattern to be used for drawing graphics paths.

CGPDFArray

An array structure within a PDF document.

CGPDFContentStream

A representation of one or more content data streams in a PDF page.

CGPDFContext

A type of CGContextRef for drawing PDF content.

CGPDFDictionary

A dictionary structure within a PDF document.

CGPDFDocument

A document that contains PDF (Portable Document Format) drawing information.

CGPDFObject

An object representing content within a PDF document.

CGPDFOperatorTable

A set of callback functions for operators used when scanning content in a PDF document.

CGPDFPage

A page in a PDF document.

CGPDFScanner

A parser object for handling content and operators in a PDF content stream.

CGPDFStream

A stream or sequence of data bytes in a PDF document.

CGPDFString

A text string in a PDF document.

CGPSConverter

An object that converts PostScript data to PDF data.

CGShading

A definition for a smooth transition between colors, controlled by a custom function you provide, for drawing radial and axial gradient fills.

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