An opaque data object that contains the drawing information captured by a canvas view.


class PKDrawingReference : NSObject


A PKDrawingReference object stores the user-drawn content from a PKCanvasView object. You use drawing objects to store the data associated with your user’s drawings. You can save this data with the rest of your app’s content, and you can use that saved data to create a new drawing object later. You can also generate an image based on the drawn content.


Creating a Drawing Object

init(data: Data)

Creates a drawing object and populates it with previously drawn content.


Creates a drawing object with no initial content.

Getting the Canvas Bounds

var bounds: CGRect

The smallest rectangle that represents the content's bounds, taking into account line widths of that content.

Generating an Image

func image(from: CGRect, scale: CGFloat) -> UIImage

Returns an image object containing the specified portion of the drawing.

Getting the Drawing Data

func dataRepresentation() -> Data

Returns an opaque representation of the rendered content.

let PKAppleDrawingTypeIdentifier: CFString

The uniform type identifier for data associated with a drawing object.

Modifying the Drawing

func applying(CGAffineTransform) -> PKDrawing

Returns a new drawing object by applying the specified transform to a copy of the current object’s contents.

func appending(PKDrawing) -> PKDrawing

Returns a copy of the current drawing object and appends the specified content to it.


Inherits From

See Also


Drawing With PencilKit

Add expressive, low-latency drawing to your application with PencilKit.

class PKCanvasView

A view that captures Apple Pencil input and displays the rendered results in an iOS app.

struct PKDrawing

An opaque data object that contains the drawing information captured by a canvas view.