Initializer

init(info:bounds:matrix:xStep:yStep:tiling:isColored:callbacks:)

Creates a pattern object.

Declaration

init?(info: UnsafeMutableRawPointer?, bounds: CGRect, matrix: CGAffineTransform, xStep: CGFloat, yStep: CGFloat, tiling: CGPatternTiling, isColored: Bool, callbacks: UnsafePointer<CGPatternCallbacks>)

Parameters

info

A pointer to private storage used by your pattern drawing function, or NULL. For more information, see the discussion below.

bounds

The bounding box of the pattern cell, specified in pattern space. (Pattern space is an abstract space that maps to the default user space by the transformation matrix you specify with the matrix parameter.) The drawing done in your pattern drawing function is clipped to this rectangle.

matrix

A matrix that represents a transform from pattern space to the default user space of the context in which the pattern is used. If no transform is needed, pass the identity matrix.

xStep

The horizontal displacement between cells, specified in pattern space. For no additional horizontal space between cells (so that each pattern cells abuts the previous pattern cell in the horizontal direction), pass the width of the pattern cell.

yStep

The vertical displacement between cells, specified in pattern space. For no additional vertical space between cells (so that each pattern cells abuts the previous pattern cell in the vertical direction), pass the height of the pattern cell.

tiling

A CGPatternTiling constant that specifies the desired tiling method.

isColored

If you want to draw your pattern using its own intrinsic color, pass true. If you want to draw an uncolored (or masking) pattern that uses the fill or stroke color in the graphics state, pass false.

callbacks

A pointer to a pattern callback function table—your pattern drawing function is an entry in this table. See CGPatternCallbacks for more information about callback function tables for patterns.

Return Value

A new Core Graphics pattern. You are responsible for releasing this object using CGPatternRelease.

Discussion

Core Graphics calls your drawing function at the appropriate time to draw the pattern cell. A pattern cell must be invariant—that is, the pattern cell should be drawn exactly the same way each time the drawing function is called.

The appearance of a pattern cell is unaffected by changes in the graphics state of the context in which the pattern is used.

See CGPatternDrawPatternCallback for more information about pattern drawing functions.

See Also

Creating Pattern Objects

enum CGPatternTiling

Different methods for rendering a tiled pattern.

struct CGPatternCallbacks

A structure that holds a version and two callback functions for drawing a custom pattern.

typealias CGPatternReleaseInfoCallback

Release private data or resources associated with the pattern.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software