iOS Developer Library

Developer

QuartzCore Framework Reference CAGradientLayer Class Reference

Options
Deployment Target:

On This Page
Language:

CAGradientLayer

Inheritance


Import Statement


Swift

import QuartzCore

Objective-C

@import QuartzCore;

Availability


Available in iOS 3.0 and later.

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

  • colors colors Property

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

    Declaration

    Swift

    var colors: [AnyObject]!

    Objective-C

    @property(copy) NSArray *colors

    Discussion

    Defaults to nil.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.0 and later.

  • locations locations Property

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

    Declaration

    Swift

    var locations: [AnyObject]!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.0 and later.

  • endPoint endPoint Property

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

    Declaration

    Swift

    var endPoint: CGPoint

    Objective-C

    @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).

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.0 and later.

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

    Declaration

    Swift

    var startPoint: CGPoint

    Objective-C

    @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).

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.0 and later.

  • type type Property

    Style of gradient drawn by the layer.

    Declaration

    Swift

    var type: String!

    Objective-C

    @property(copy) NSString *type

    Discussion

    Defaults to kCAGradientLayerAxial.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.0 and later.

  • The style of gradient drawn by the layer.

    Declaration

    Swift

    let kCAGradientLayerAxial: String

    Objective-C

    NSString * const kCAGradientLayerAxial

    Constants

    • kCAGradientLayerAxial

      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.