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.

Symbols

Creating Color Objects

init?(colorSpace: CGColorSpace, components: UnsafePointer<CGFloat>)

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

func copy()

Creates a copy of an existing color.

init(gray: CGFloat, alpha: CGFloat)

Creates a color in the Generic gray color space.

init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)

Creates a color in the Generic RGB color space.

func copy(alpha: CGFloat)

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

init?(patternSpace: CGColorSpace, pattern: CGPattern, components: UnsafePointer<CGFloat>)

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

func converted(to: CGColorSpace, intent: CGColorRenderingIntent, options: CFDictionary?)

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

Getting Information about Core Graphics Colors

var alpha: CGFloat

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

var colorSpace: CGColorSpace?

Returns the color space associated with a color.

var numberOfComponents: Int

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

var pattern: CGPattern?

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

class var typeID: CFTypeID

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

Data Types

CGColor

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

Constants

Constant Colors

Commonly used colors.