One Logo Pool Ball
PencilKit · IOS API REFERENCE

PKDrawing

struct · iOS 13.0+ · SDK 27.1

struct PKDrawing

Members (16)

method · iOS 27.0+

erasingPath

TypeScript
erasingPath(eraserPath: PKStrokePath, mask?: (_UIKit_UIBezierPath) | null, transform?: _CoreFoundation_CGAffineTransform): PKDrawing
Swift declaration
func erasingPath(_ eraserPath: PKStrokePath, mask: UIBezierPath? = nil, transform: CGAffineTransform = .identity) -> PKDrawing
method · iOS 13.0+

transformed

TypeScript
transformed(transform: _CoreFoundation_CGAffineTransform): PKDrawing
Swift declaration
func transformed(using transform: CGAffineTransform) -> PKDrawing

Returns a new drawing with the specified transform applied. - parameter transform: The transform to apply to this drawing. - returns: A new copy of this drawing with `transform` applied.

method · iOS 13.0+

dataRepresentation

TypeScript
dataRepresentation(): ArrayBuffer
Swift declaration
func dataRepresentation() -> Data
get · iOS 17.0+

requiredContentVersion

TypeScript
get requiredContentVersion(): PKContentVersion
Swift declaration
var requiredContentVersion: PKContentVersion { get }

The PencilKit version required to use this drawing.

init · iOS 13.0+

init

TypeScript
static initData(data: ArrayBuffer): PKDrawing
Swift declaration
init(data: Data) throws
method · iOS 26.0+

draw

TypeScript
draw(cgContext: _CoreGraphics_CGContext, frame: { x: number; y: number; width: number; height: number }, sourceRect: { x: number; y: number; width: number; height: number }, darkUserInterfaceStyle?: boolean): Promise<void>
Swift declaration
nonisolated(nonsending) func draw(in cgContext: CGContext, frame: CGRect, from sourceRect: CGRect, darkUserInterfaceStyle: Bool = false) async

Draws the drawing in the specified rectangle. - Parameters: - context: The graphics context to render into. - frame: The rectangle (in the coordinate system of the graphics context) in which to draw the drawing. - sourceRect: The rectangle (in the drawing coordinate system) from which to draw. - darkUserInterfaceStyle: Use a dark user interface style for rendering.

method · iOS 13.0+

image

TypeScript
image(rect: { x: number; y: number; width: number; height: number }, scale: number): _UIKit_UIImage
Swift declaration
func image(from rect: CGRect, scale: CGFloat) -> UIImage
method · iOS 13.0+

append

TypeScript
append(toAppend: PKDrawing): void
Swift declaration
mutating func append(_ toAppend: PKDrawing)

Appends the contents of the specified drawing on top of this drawing. - parameter drawing: The drawing to append.

get · iOS 13.0+

bounds

TypeScript
get bounds(): { x: number; y: number; width: number; height: number }
Swift declaration
var bounds: CGRect { get }

The bounds of the drawing's contents. Use these bounds to render an image that includes all content without cropping.

init · iOS 14.0+

init

TypeScript
static initStrokes(strokes: Array<PKStroke>): PKDrawing
Swift declaration
init<S>(strokes: S) where S : Sequence, S.Element == PKStroke

Creates a drawing with the specified strokes. When setting strokes, duplicate IDs are automatically resolved by generating new UUIDs for conflicting strokes. The first occurrence keeps its original ID.

get · iOS 14.0+

strokes

TypeScript
get strokes(): Array<PKStroke>
Swift declaration
var strokes: [PKStroke] { get set }

The strokes the drawing contains. When setting strokes, duplicate IDs are automatically resolved by generating new UUIDs for conflicting strokes. The first occurrence keeps its original ID.

set · iOS 14.0+

strokes

TypeScript
set strokes(value: Array<PKStroke>)
Swift declaration
var strokes: [PKStroke] { get set }

The strokes the drawing contains. When setting strokes, duplicate IDs are automatically resolved by generating new UUIDs for conflicting strokes. The first occurrence keeps its original ID.

method · iOS 13.0+

appending

TypeScript
appending(toAppend: PKDrawing): PKDrawing
Swift declaration
func appending(_ toAppend: PKDrawing) -> PKDrawing

Returns a new drawing with the contents of the specified drawing appended. - parameter drawing: The drawing to append. - returns: A new copy of this drawing with `drawing` appended.

method · iOS 27.0+

erasePath

TypeScript
erasePath(eraserPath: PKStrokePath, mask?: (_UIKit_UIBezierPath) | null, transform?: _CoreFoundation_CGAffineTransform): void
Swift declaration
mutating func erasePath(_ eraserPath: PKStrokePath, mask: UIBezierPath? = nil, transform: CGAffineTransform = .identity)
method · iOS 13.0+

transform

TypeScript
transform(transform: _CoreFoundation_CGAffineTransform): void
Swift declaration
mutating func transform(using transform: CGAffineTransform)

Applies the specified transform to the contents of the drawing. - parameter transform: The transform to apply to this drawing.

init · iOS 13.0+

init

TypeScript
static init(): PKDrawing
Swift declaration
init()

Skipped declarations

No declarations were skipped in this snapshot.

All PencilKit types →