CAGradientLayer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/QuartzCore.framework
Availability
Available in iOS 3.0 and later.
Declared in
CAGradientLayer.h
Related sample code

Overview

The CAGradientLayer class draws a color gradient over its background color, filling the shape of the layer (including rounded corners)

Tasks

Gradient Style Properties

Properties

colors

An array of CGColorRef objects defining the color of each gradient stop. Animatable.

@property(copy) NSArray *colors
Discussion

Defaults to nil.

Availability
  • Available in iOS 3.0 and later.
Declared In
CAGradientLayer.h

endPoint

The end point of the gradient when drawn in the layer’s coordinate space. Animatable.

@property CGPoint endPoint
Discussion

The end point corresponds to the last stop of the gradient. The point is defined in the unit coordinate space and is then mapped to the layer’s bounds rectangle when drawn.

Default value is (0.5,1.0).

Availability
  • Available in iOS 3.0 and later.
Declared In
CAGradientLayer.h

locations

An optional array of NSNumber objects defining the location of each gradient stop. Animatable.

@property(copy) NSArray *locations
Discussion

The gradient stops are specified as values between 0 and 1. The values must be monotonically increasing. If nil, the stops are spread uniformly across the range. Defaults to nil.

When rendered, the colors are mapped to the output color space before being interpolated.

Availability
  • Available in iOS 3.0 and later.
Declared In
CAGradientLayer.h

startPoint

The start point of the gradient when drawn in the layer’s coordinate space. Animatable.

@property CGPoint startPoint
Discussion

The start point corresponds to the first stop of the gradient. The point is defined in the unit coordinate space and is then mapped to the layer’s bounds rectangle when drawn.

Default value is (0.5,0.0).

Availability
  • Available in iOS 3.0 and later.
Declared In
CAGradientLayer.h

type

Style of gradient drawn by the layer.

@property(copy) NSString *type
Discussion

Defaults to kCAGradientLayerAxial.

Availability
  • Available in iOS 3.0 and later.
Declared In
CAGradientLayer.h

Constants

Gradient Types

The style of gradient drawn by the layer.

NSString * const kCAGradientLayerAxial
Constants
kCAGradientLayerAxial

An axial gradient (also called a linear gradient) varies along an axis between two defined end points. All points that lie on a line perpendicular to the axis have the same color value.

Available in iOS 3.0 and later.

Declared in CAGradientLayer.h.