Check out how you can add strokes to PKDrawing with this WWDC session - https://developer.apple.com/videos/play/wwdc2020/10148/
[tags:wwdc20-10107]
9 results found
Post
Replies
Boosts
Views
Activity
How to add strokes to PKDrawing in PKCanvasView programmatically?
I implemented a drawing canvas before PencilKit was released. The drawings were stored as PNGData. Is there a way to convert PNGData or a UIImage to a PKDrawing so I can migrate to PencilKit?
Any luck with this @adamwulf? I'm trying to do something similar in supporting some pre-PencilKit drawing data. I've been able to serialize my data into and out of PKDrawing data, but am struggling with eraser support.
Related to this: I have a drawing canvas as well, and have stored the history for all ink/eraser paths. I'd like to migrate that data into a PKDrawing. It seems that migrating ink can be done by creating new PKStrokes with the point/path/ink data I have. However, I don't see a way to migrate eraser paths. Is there a way to generate new eraser strokes programmatically for a PKDrawing?
There is not an API to convert from image data into a PencilKit drawing. It is possible to synthesize PencilKit drawings using APIs added in iOS 14. For details check out this session: Inspect, modify, and construct PencilKit drawings - https://developer.apple.com/videos/play/wwdc2020/10148/.
Shape detection for Apple Pencil drawing was mentioned as a new feature during the keynote, but I did not see it mentioned in the What's new in PencilKit video and it does not seem to work in a test app I created in iOS 14 Beta 1 using PKCanvasView. It does work in the iOS 14 Notes app. Will this be made available in the public library? It would be so great to have!
Ah that’s too bad :(
Shape Detection is only supported in Notes, Screenshots & Markup in iOS 14.