PKCanvasView
A view that captures Apple Pencil input and displays the rendered results in an iOS app.
Declaration
class PKCanvasViewMentioned in
Overview
A PKCanvasView object captures content drawn using Apple Pencil or the user’s finger and displays it in your app. 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 PKDrawingReference 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 that the user can choose from. As the user interacts with items in the palette, such as changing ink colors, or line widths, the canvas automatically updates its drawing environment accordingly.