iOS Developer Library

Developer

ApplicationServices Framework Reference CGShading Reference

Options
Deployment Target:

On This Page
Language:

CGShading Reference

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreGraphics

Objective-C

@import CoreGraphics;

CGShadingRef is an opaque type used to define linear (axial) and radial gradient fills whose color transitions are controlled by a function (CGFunctionRef) that you provide. Shading means to fill using a smooth transition between colors across an area. To paint with a Quartz shading, you call CGContextDrawShading. This function fills the current clipping path using the specified color gradient, calling your parametric function repeatedly as it draws

An alternative to using a CGShading object is to use the CGGradientRef opaque type. For applications that run in OS X v10.5 and later, CGGradient objects are much simpler to use. (See CGGradient Reference.)

Functions

  • Creates a shading object to use for axial shading.

    Declaration

    Swift

    func CGShadingCreateAxial(_ colorspace: CGColorSpace!, _ start: CGPoint, _ end: CGPoint, _ function: CGFunction!, _ extendStart: Bool, _ extendEnd: Bool) -> CGShading!

    Objective-C

    CGShadingRef CGShadingCreateAxial ( CGColorSpaceRef space, CGPoint start, CGPoint end, CGFunctionRef function, bool extendStart, bool extendEnd );

    Parameters

    colorspace

    The color space in which color values are expressed. Quartz retains this object; upon return, you may safely release it.

    start

    The starting point of the axis, in the shading's target coordinate space.

    end

    The ending point of the axis, in the shading's target coordinate space.

    function

    A CGFunction object created by the function CGFunctionCreate. This object refers to your function for creating an axial shading. Quartz retains this object; upon return, you may safely release it.

    extendStart

    A Boolean value that specifies whether to extend the shading beyond the starting point of the axis.

    extendEnd

    A Boolean value that specifies whether to extend the shading beyond the ending point of the axis.

    Return Value

    A new Quartz axial shading. You are responsible for releasing this object using CGShadingRelease.

    Discussion

    An axial shading is a color blend that varies along a linear axis between two endpoints and extends indefinitely perpendicular to that axis. When you are ready to draw the shading, call the function CGContextDrawShading.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later

  • Creates a shading object to use for radial shading.

    Declaration

    Swift

    func CGShadingCreateRadial(_ colorspace: CGColorSpace!, _ start: CGPoint, _ startRadius: CGFloat, _ end: CGPoint, _ endRadius: CGFloat, _ function: CGFunction!, _ extendStart: Bool, _ extendEnd: Bool) -> CGShading!

    Objective-C

    CGShadingRef CGShadingCreateRadial ( CGColorSpaceRef space, CGPoint start, CGFloat startRadius, CGPoint end, CGFloat endRadius, CGFunctionRef function, bool extendStart, bool extendEnd );

    Parameters

    colorspace

    The color space in which color values are expressed. Quartz retains this object; upon return, you may safely release it.

    start

    The center of the starting circle, in the shading's target coordinate space.

    startRadius

    The radius of the starting circle, in the shading's target coordinate space.

    end

    The center of the ending circle, in the shading's target coordinate space.

    endRadius

    The radius of the ending circle, in the shading's target coordinate space.

    function

    A CGFunction object created by the function CGFunctionCreate. This object refers to your function for creating a radial shading. Quartz retains this object; upon return, you may safely release it.

    extendStart

    A Boolean value that specifies whether to extend the shading beyond the starting circle.

    extendEnd

    A Boolean value that specifies whether to extend the shading beyond the ending circle.

    Return Value

    A new Quartz radial shading. You are responsible for releasing this object using CGShadingRelease.

    Discussion

    A radial shading is a color blend that varies between two circles. To draw the shading, call the function CGContextDrawShading.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later

  • Increments the retain count of a shading object.

    Declaration

    Objective-C

    CGShadingRef CGShadingRetain ( CGShadingRef shading );

    Parameters

    shading

    The shading object to retain.

    Return Value

    The same shading object you passed in as the shading parameter.

    Discussion

    This function is equivalent to CFRetain, except that it does not cause an error if the shading parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in iOS 2.0 and later

  • Decrements the retain count of a shading object.

    Declaration

    Objective-C

    void CGShadingRelease ( CGShadingRef shading );

    Parameters

    shading

    The shading object to release.

    Discussion

    This function is equivalent to CFRelease, except that it does not cause an error if the shading parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in iOS 2.0 and later

  • Returns the Core Foundation type identifier for Quartz shading objects.

    Declaration

    Swift

    func CGShadingGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CGShadingGetTypeID ( void );

    Return Value

    The Core Foundation identifier for the opaque type CGShadingRef.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later

Data Types

  • An opaque type that represents a Quartz shading.

    Declaration

    Swift

    typealias CGShadingRef = CGShading

    Objective-C

    typedef struct CGShading *CGShadingRef;

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later