Class

PKCanvasView

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

Declaration

@interface PKCanvasView : UIScrollView

Overview

A PKCanvasView object captures content drawn using Apple Pencil or the user’s finger and displays it in your app. Add a canvas view to your interface when you want to capture or display user-drawn content. The canvas view handles all of the touch events and data coming from Apple Pencil, and renders that information using the tool you specify. The canvas stores the captured input in a PKDrawing object.

PKCanvasView is a scroll view, so you can make the drawable area bigger than the canvas view’s frame rectangle. To do that, set the inherited contentSize property to the size you want. The canvas view automatically scales its underlying content to match the size you specify. Users scroll around the canvas using a two-finger pan gesture. (If the allowsFingerDrawing property is false, users scroll with only one finger.)

A canvas view conforms to the PKToolPickerObserver protocol, so you can add it as an observer of the window’s tool picker. The tool picker displays a floating palette of tools for the user to choose from. As the user interacts with items in the palette, the canvas automatically updates its drawing environment accordingly.

Topics

Responding to Drawing-Related Changes

delegate

The object you use to respond to changes in the drawn content or in the selected tool.

PKCanvasViewDelegate

Methods you use to track editing-related changes in a canvas view.

Configuring the Drawing Environment

tool

The currently selected tool for drawing.

rulerActive

A Boolean value that indicates whether a ruler view is currently visible on the canvas.

allowsFingerDrawing

A Boolean value that indicates whether the canvas accepts input from the user’s finger in addition to Apple Pencil.

Getting the Drawing Gesture Recognizer

drawingGestureRecognizer

The gesture recognizer that the canvas uses to track touch events.

Getting the Captured Data

drawing

The data object that the canvas uses to store drawn content.

Relationships

Inherits From

See Also

Canvas

PKDrawing

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