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 ?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With