What's new in PencilKit
Description: PencilKit helps power creativity, writing, drawing, and animation in your iPad apps. Explore the latest improvements to our drawing and annotation framework, and discover how you can take advantage of APIs like PKToolPicker, PKCanvasView, and PKStroke to support new features in illustration and writing apps. To get the most out of this session, you should have a basic understanding of PencilKit. If you want to a refresher, “Introduction to PencilKit” from WWDC19 is a great place to start.
New fatures
- Rich-selection experience:
- Double-tap to select a word
- Double-tap again to select a line
- Grab selection handles to expand your selection
- Enhanced tap-and-pan gesture: you can make noncontiguous selections by brushing over specific strokes
- Add space between scribbles/notes:
- Tap on the space between two lines
- Tap
Insert Space
from the callout bar - Use the grab handle to adjust the amount of space
- New color picker:
- Saved colors
- Eye dropper
- Catalyst support
Pencil vs hand drawing
- New (iOS 14 only) system settings for users to choose if they would like to draw only with the pencil or with fingers as well.
- All apps need to respect that, if you have your own drawing engine, check
UIPencilInteraction.prefersPencilOnlyDrawing
- This can also be toggled directly on the tool picker:
PKCanvasView
has been updated to reflect this preference with the newdrawingPolicy
, these are the possible values/behaviors:anyInput
: allows drawing on the canvas from any input sourcepencilOnly
: pencil touches are the only input that draw on the canvasdefault
:- if the tool picker is displayed, it follows
UIPencilInteraction.prefersPencilOnlyDrawing
- if the tool picker is hidden, it's the same as
pencilOnly
- if the tool picker is displayed, it follows
- If you'd like to hide the
Draw with Finger
option in the tool picker (for example when your app is a pencil-only app) set thePKToolPicker.showsDrawingPolicyControls
tofalse
.
- You can also create your own
PKToolPicker
instances:- Need to be retained by your app
- Each toolpicker can be used with different states with different canvases
Strokes Access
- PencilKit in iOS 14 provides access to strokes, for more, check session
Inspect, modify, and construct PencilKit drawings