9

I'm trying to figure out how to modify the PKDrawing property from PKCanvasView to add some shapes like circles or at least add a line however PKDrawing is an opaque type so there is not too much to do.

Is there any workaround to create shapes or lines on a PKCanvasView ?

byaruhaf
  • 4,128
  • 2
  • 32
  • 50
  • I have been searching high and low for an answer to this. From what I can tell you cannot programmatically modify the data in a PKDrawing object – Nathan Stowell Apr 06 '20 at 05:55

2 Answers2

2

You can now

yourPKCanvasView.drawing = PKDrawing(strokes: yourPKStrokes)

Full example: https://developer.apple.com/documentation/pencilkit/inspecting_modifying_and_constructing_pencilkit_drawings

Sam
  • 31
  • 5
1

If you're looking to create the drawing 100% programmatically, from raw CGPoints, instead of from a predefined asset like in Apple's examples, see https://stackoverflow.com/a/70274331/4075379

Roger Oba
  • 1,292
  • 14
  • 28