스트리밍은 대부분의 브라우저와
Developer 앱에서 사용할 수 있습니다.
-
PencilKit의 새로운 기능
PencilKit을 사용하면 iPad 앱에서 창의적인 활동을 장려하고 글, 그림, 애니메이션을 더 다채롭게 꾸밀 수 있습니다. 그림 및 프레임워크의 최신 개선 사항을 살펴보고 PKToolPicker, PKCanvasView, PKStroke와 같은 API를 활용하여 그리기 및 글쓰기 앱의 신규 기능을 지원하는 방법을 알아보세요. 이 세션을 최대한 활용하려면 PencilKit에 대한 기본 지식을 숙지하시는 것이 좋습니다. PencilKit에 대한 기본 지식을 복습하고 싶으시다면 WWDC19의 ‘PencilKit 소개'를 참고해 주세요.
리소스
관련 비디오
WWDC20
WWDC19
-
다운로드
Hello and welcome to WWDC.
Hi. I'm Jenny, and I'm an engineer on the Pencil and Paper team. Welcome to "What's New in PencilKit." In iOS 13, we introduced PencilKit, a new framework for easily adding a low-latency expressive drawing experience to your app. In iOS 14, we've added some new features to the out-of-the-box PencilKit experience. Next, we'll go over some of the changes we've made to the finger versus pencil drawing policy across the system. Finally, we'll cover some API changes that we've made, in addition to a sneak peek at some of the new APIs that we're exposing that will really expand the possibilities of what you can do with PencilKit. In iOS 13, we showed you how you can adopt PencilKit with only a few lines of code with PKCanvasView. It was great to see how you adopted it. If you haven't adopted PencilKit yet, check out our talk from 2019 to see just how easy it is. The Apple Pencil has so much potential, and it can really unlock the capabilities of productivity and the iPad. And so, we can't wait to show you some of the new enhancements that we've added to the PencilKit experience, and the best part is that they require zero adoption.
PencilKit documents have gotten smarter as we infuse intelligence across handwritten notes. We've provided a rich-selection experience that mirrors the way that you select type text. So you can double-tap for a word, double-tap again to select a line, or even use the grab handles to expand your selection.
We've improvised some enhanced gestures, like a velocity-sensitive tap-and-pan so that you can make noncontiguous selections by brushing over specific strokes.
We've also introduced an easy way to insert space between your handwritten content. Have you ever written stuff and realized you've forgotten something right in between? Instead of having to write super tiny and squeeze additions in the margins, you can just tap on the white space, tap "Insert Space" from the callout bar, use the grab handle to adjust the amount of space...
and then easily add the new content in between.
We also adopted the new UIKit system standard color picker, which features rich new ways to choose more colors for your drawings. You'll have a rainbow of color options using the spectrum or sliders, be able to save your custom colors for later, or even use the eye dropper to sample colors. For existing PencilKit clients, there's nothing that you'll need to add to your app. You'll get it for free. For more information about how to easily adopt this, check out the UIKit talk, "Build With iOS Pickers, Menus and Actions." We've also made some great latency optimizations for third parties. In iOS 13, we recommended techniques to avoid impacting latency, such as avoiding any visual effect views or blur effects. In iOS 14, that's no longer the case, and you can use different visual effect view materials and bars to your heart's content.
In addition, we've also added PKCanvasView support for Catalyst. The tool picker is not supported, but you can easily set inks on the canvas through the PKCanvasView APIs. And, just as a reminder, for smart selection, insert space, and the new color picker, no extra adoption is required. And that's why we made it a system-wide experience so we could keep enhancing it year after year, providing a consistent enhanced experience across the system. We've also done some work to distinguish the finger versus Pencil drawing experience and how it can be more unified across the system. PencilKit is supported on both phones and iPads. Drawing with both finger and Apple Pencil is allowed, and you have to remember that not everyone has a Pencil.
In iOS 13, we introduced the allowsFingerDrawing property, which meant that if you had it on, one finger would draw, while two fingers would scroll.
In iOS 14, we have a new global setting that can be set from the new Apple Pencil menu in settings via the Prefer Only Pencil Drawing toggle. This is for all third parties who use Pencil, both for apps who adopted PencilKit, and for those with their own drawing engine.
This setting can be accessed via UIPencilInteraction in UIKit. Non-PencilKit clients that have their own drawing engine should respect the setting by querying UIPencilInteraction.prefersPencilOnlyDrawing parameter. On the phone, this value is always "false," as finger is your only drawing tool available.
On the other hand, PencilKit clients get this for free, as it's surfaced in the tool picker. This toggles the global setting that you see in the settings pane. So when the Draw with Finger switch is toggled on in Notes, then that means it will also be turned on across the system, such as screenshots, Markup, other PencilKit clients, and the new value will also be reflected in settings.
We've also updated the call on PKCanvasView to account for this new global finger drawing toggle. We've deprecated allowsFingerDrawing in favor of setting the PKCanvasViewDrawingPolicy on the canvas.
Please do not set the drawing gesture recognizer allowedTouchTypes, and instead set the drawing policy on the canvas to control Pencil vs finger touches.
There are three different kinds of drawing policies. The first, PKCanvasViewDrawingPolicy.anyInput, means that you allow any input, allowing both finger and Pencil drawing.
The second policy, pencilOnly, means you only allow Pencil, so finger will scroll or do smart selection gestures.
The third, which is the default, is dependent on if the tool picker is hidden or not. If the tool picker is visible, it respects UIPencilInteraction's prefersPencilOnlyDrawing state, a.k.a, what the user set in settings or toggled in the tool picker.
If the tool picker is hidden, then only Pencil will ever draw. Whenever finger scrolls, you can also perform smart selection gestures. Let me show you. You don't even have to choose the lasso tool. When the pen is selected, you can scroll and perform smart selection gestures on your handwritten content so that you can easily go back and forth between writing...
and selecting.
If your app is purely a Pencil app, you might not want to show the Draw With Finger toggle. To turn this off in the UI, you'll need to set PKToolPicker.showsDrawingPolicyControls to false. By default, it will always be true on iPads, meaning they will always show the Draw With Finger toggle in the tool picker. If the canvas drawing policy is set to Pencil only, you'll want to set this to false, so users won't be confused when they flip the switch and nothing changes on the canvas.
We've also updated the PKToolPicker initialization methods. Instead of having a single shared tool picker for a UIWindow, you can now initialize individual instances of the tool picker. By doing so, you can now have independent PKToolPickers with their own state.
Given this state, it's useful to have multiple tool pickers for different canvases or windows in your app. However, one of the implications of this is that you must always retain your own tool picker instance by having an Ivar reference it.
And so, when should you have a single instance versus creating a new one? As a refresher from our "Introducing PencilKit" talk, you may have other UI responders that set visible to "true" to keep the tool picker visible.
You should always pass your unique tool picker instance around to each of these responders.
On the other hand, when do you need separate tool pickers? Let's say my app has two modes, a note-taking mode and a coloring mode.
My note-taking canvas wants a default drawing policy, versus I want to allow both finger and Pencil drawing on my coloring canvas.
In this case, each of the canvases should have their own unique tool picker instance with their own unique state, since I'll want to hide the drawing policy controls on my coloring canvas.
The tool pickers will also have different states in terms of their selected tool. I'll make the selected tool on my notes canvas a black pen, while my coloring canvas will have a purple marker as the default. The tool pickers in your app might also have other varying states, such as different color user interface styles if you're drawing versus marking up an image.
Finally, one of the biggest changes we made to PencilKit in iOS 14 is providing access to strokes, letting you peek inside the internals of PKDrawing. With the strokes, you'll be able to access inks, paths, points, and more.
For more information, check out the "Inspect, Modify and Construct PencilKit Drawings" talk. Access to strokes can unlock so many more interesting custom PencilKit experiences involving annotations, animations, recognition, and machine learning.
And that's what's new in PencilKit. For existing PencilKit clients, you'll get some new feature enhancements with zero adoption, including smart selection, insert space, and the new color picker.
Move away from the deprecated APIs to the new APIs to make sure that you provide the best finger and Pencil drawing experience.
And, finally, you can introspect the strokes inside of PKDrawing with some new PencilKit APIs, taking your Pencil experience to the next level. Thanks for watching, and we're looking forward to seeing what you will do with PencilKit.
-
-
5:21 - PKCanvasView drawingPolicy
var drawingPolicy: PKCanvasViewDrawingPolicy
-
7:06 - PKToolPicker showDrawingPolicyControls
PKToolPicker.showsDrawingPolicyControls
-
8:40 - Toolpicker per canvas
notesCanvas.drawingPolicy = .default notesToolPicker.showsDrawingPolicyControls = true notesToolPicker.selectedTool = PKInkingTool(.pen, color: .black, width: 2) drawingCanvas.drawingPolicy = .anyInput drawingToolPicker.showsDrawingPolicyControls = false drawingToolPicker.selectedTool = PKInkingTool(.marker, color: .purple, width: 20)
-
-
찾고 계신 콘텐츠가 있나요? 위에 주제를 입력하고 원하는 내용을 바로 검색해 보세요.
쿼리를 제출하는 중에 오류가 발생했습니다. 인터넷 연결을 확인하고 다시 시도해 주세요.