CGGradient

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

Overview

A gradient defines a smooth transition between colors across an area. A CGGradient object has a color space, two or more colors, and a location for each color. The color space cannot be a pattern or indexed color space, otherwise it can be any Core Graphics color space (CGColorSpace).

Colors can be provided as component values (such as red, green, blue) or as Core Graphics color objects (CGColor). Component values can vary from 0.0 to 1.0, designating the proportion of the component present in the color.

A location is a normalized value. When it comes time to paint the gradient, Core Graphics maps the normalized location values to the points in coordinate space that you provide.

For more precise control over gradients, see CGShading.

Symbols

Creating a CGGradient Object

init?(colorSpace: CGColorSpace, colorComponents: UnsafePointer<CGFloat>, locations: UnsafePointer<CGFloat>?, count: Int)

Creates a CGGradient object from a color space and the provided color components and locations.

init?(colorsSpace: CGColorSpace?, colors: CFArray, locations: UnsafePointer<CGFloat>?)

Creates a CGGradient object from a color space and the provided color objects and locations.

Getting the Type ID for a CGGradient Object

class var typeID: CFTypeID

Returns the Core Foundation type identifier for CGGradient objects.

Data Types

CGGradient

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

Constants

CGGradientDrawingOptions

Drawing locations for gradients.