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 CGGradientRef 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 (CGColorSpaceRef).

Colors can be provided as component values (such as red, green, blue) or as Core Graphics color objects (CGColorRef). 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.

Topics

Creating a CGGradient Object

CGGradientCreateWithColorComponents

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

CGGradientCreateWithColors

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

Retaining and Releasing a CGGradient Object

CGGradientRelease

Decrements the retain count of a CGGradient object.

CGGradientRetain

Increments the retain count of a CGGradient object.

Getting the Type ID for a CGGradient Object

CGGradientGetTypeID

Returns the Core Foundation type identifier for CGGradient objects.

Data Types

CGGradientRef

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

Constants

CGGradientDrawingOptions

Drawing locations for gradients.

See Also

Opaque Types

CGBitmapContext

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

CGColor

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

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.

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.