2

Situation

In my iOS app, I have a feature where I can take a picture and then, draw on it. I currently use an old Cocoapods library and I would like to switch to PencilKit.

Problem

Documentation and online tutorial are very unclear on the process/result. Is it supported by the framework to draw on an image ? Lots of SO post are saying to put the image in the background with a transparent PKCanvasView. that's seems a bit of a hack. Will it support cropping image ?

What I want

My goal is to achieve something similar as to what we have when we take a screenshot. An image that you can crop and draw on. Is the post-screenshot UI based on PencilKit? How can I achieve that ?

koen
  • 5,383
  • 7
  • 50
  • 89
Maxime Lapointe
  • 193
  • 1
  • 5

1 Answers1

0

You can put an image in the background and draw on by inserting an UIImageView as a subview to a PKCanvasView:

let canvasView = PKCanvasView()
canvasView.isOpaque = true
let imageView = UIImageView(image: UIImage(systemName: "pencil"))
canvasView.insertSubview(imageView, at: 1)
Cihan
  • 26
  • 1
  • 2