Class

PKDrawingReference

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

Declaration

class PKDrawingReference : NSObject

Overview

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.

Topics

Creating a Drawing Object

init(data: Data)

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

init()

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.

Relationships

Inherits From

See Also

Canvas

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.

Beta
struct PKDrawing

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

Beta

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