---
title: CGPattern
framework: coregraphics
role: symbol
role_heading: Class
path: coregraphics/cgpattern
---

# CGPattern

A 2D pattern to be used for drawing graphics paths.

## Declaration

```swift
class CGPattern
```

## Overview

Overview Core Graphics tiles the pattern cell for you, based on parameters you specify when you call init(info:bounds:matrix:xStep:yStep:tiling:isColored:callbacks:). To create a dashed line, see CGContextSetLineDash.

## Topics

### Creating a Pattern

- [init(info:bounds:matrix:xStep:yStep:tiling:isColored:callbacks:)](coregraphics/cgpattern/init(info:bounds:matrix:xstep:ystep:tiling:iscolored:callbacks:).md)

### Callbacks

- [CGPatternCallbacks](coregraphics/cgpatterncallbacks.md)
- [CGPatternDrawPatternCallback](coregraphics/cgpatterndrawpatterncallback.md)
- [CGPatternReleaseInfoCallback](coregraphics/cgpatternreleaseinfocallback.md)

### Constants

- [CGPatternTiling](coregraphics/cgpatterntiling.md)

### Working with Core Foundation Types

- [typeID](coregraphics/cgpattern/typeid.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)
- [CGShading](coregraphics/cgshading.md)
- [CGGradient](coregraphics/cggradient.md)
- [CGFunction](coregraphics/cgfunction.md)
