---
title: CGShading
framework: coregraphics
role: symbol
role_heading: Class
path: coregraphics/cgshading
---

# CGShading

A definition for a smooth transition between colors, controlled by a custom function you provide, for drawing radial and axial gradient fills.

## Declaration

```swift
class CGShading
```

## Overview

Overview Shading means to fill using a smooth transition between colors across an area. You create a shading using a custom function with a CGFunction instance. To paint with a Core Graphics shading, you call drawShading(_:). 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 instance is to use the CGGradient type. For applications that run in macOS 10.5 and later, CGGradient objects are much simpler to use.

## Topics

### Creating Shading Objects

- [init(axialSpace:start:end:function:extendStart:extendEnd:)](coregraphics/cgshading/init(axialspace:start:end:function:extendstart:extendend:).md)
- [init(radialSpace:start:startRadius:end:endRadius:function:extendStart:extendEnd:)](coregraphics/cgshading/init(radialspace:start:startradius:end:endradius:function:extendstart:extendend:).md)

### Working with Core Foundation Types

- [typeID](coregraphics/cgshading/typeid.md)

### Initializers

- [init(axialHeadroom:space:start:end:function:extendStart:extendEnd:)](coregraphics/cgshading/init(axialheadroom:space:start:end:function:extendstart:extendend:).md)
- [init(radialHeadroom:space:start:startRadius:end:endRadius:function:extendStart:extendEnd:)](coregraphics/cgshading/init(radialheadroom:space:start:startradius:end:endradius:function:extendstart:extendend:).md)

### Instance Properties

- [contentHeadroom](coregraphics/cgshading/contentheadroom.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Quartz 2D Programming Guide](apple-archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction.md)

### Utility and Support Classes

- [CGDataConsumer](coregraphics/cgdataconsumer.md)
- [CGDataProvider](coregraphics/cgdataprovider.md)
- [CGGradient](coregraphics/cggradient.md)
- [CGFunction](coregraphics/cgfunction.md)
- [CGPattern](coregraphics/cgpattern.md)
