A view that captures Apple Pencil input and displays the rendered results in an iOS app.
- iOS 13.0+Beta
PKCanvas 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
PKCanvas 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
content 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
allows property is false, users scroll with only one finger.)
A canvas view conforms to the
PKTool 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.