From the course: iPadOS 13 Development Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with a PKCanvasView

Working with a PKCanvasView - iOS Tutorial

From the course: iPadOS 13 Development Essential Training

Start my 1-month free trial

Working with a PKCanvasView

- [Instructor] PencilKit is an excellent tool to use in iPadOS 13 and iOS 13. It enables you to quickly and easily create a drawing canvas and add drawing tools to your project. Let's take a look at the core element of PencilKit, which is the PKCanvasView. We'll start by importing PencilKit into our project. Once we've done that, we're going to create a struct called CanvasView that extends UIViewRepresentable. This is going to be our canvas. We'll need to implement the usual method, which is makeUIView and updateUIView. By the way, if you're wondering how to use updateUIView, if you have a binding variable inside of this struct, then updateUIView will get called whenever you initialize the object and whenever that binding variable gets updated. So let's change some UIView to PKCanvasView. We'll do that in both places. And then in here, we're going to create a canvasView, and then return it. And that's it. Inside of…

Contents