Questions tagged [pencilkit]

PencilKit is Apple's framework for capturing touch input as an opaque drawing and displaying that content from your app.

PencilKit is Apple's framework for capturing touch input as an opaque drawing and displaying that content from your app.

Apple first revealed PencilKit at WWDC on June 3, 2019, and made it available in the first beta release of Xcode 11.

PencilKit is part of the following SDKs:

  • iOS 13.0 and later,
  • macOS 10.15 and later,
  • Mac Catalyst 13.0 and later.
140 questions
0
votes
1 answer

Real-time drawing synchronization between PKCanvasView on iPad and external screen

Situation: I'm developing an iPad app using SwiftUI, and I have an external screen connected to the iPad. In my app, I want to provide a drawing feature using PKCanvasView. The goal is to allow users to draw on the iPad screen and have the drawing…
wades
  • 250
  • 2
  • 10
0
votes
1 answer

Showing/Hiding PKToolPicker with SwiftUI

I am having two issues using PKToolPicker with SwiftUI. The first issue is that once I draw on the canvas view, toggling the visibility of the PKToolPicker doesn't make it go away. The second issue is that sometimes the PKToolPicker doesn't go away…
Jake
  • 13,097
  • 9
  • 44
  • 73
0
votes
2 answers

PKCanvas mysteriously returns original drawing, how?

MRE I've spent so many hours trying to figure out whats happening but I cant figure it out struct ContentView: View { @State private var canvasView = PKCanvasView() @State private var rendition = PKDrawing() func save() { …
erotsppa
  • 14,248
  • 33
  • 123
  • 181
0
votes
0 answers

Find the ID of selected strokes by PKLassoTool

I'm trying to create an iPad App to draw on a canvas with polygon detection and I'm using PencilKit. My problem is that when I select a stroke with PKLassoTool I need to find the ID of that stroke in the canvas in order to custom modify it. Is there…
0
votes
0 answers

Disable "Undo added strokes" popup in Swift and PKCanvasView

Currently if a user has created a stroke and shakes with the Apple Pencil and then shakes the iPad, a pop up saying 'Undo Added strokes" pops up. We want to remove this from the app for pencil kit. Currently, Apple's documentation suggests that we…
Osian
  • 171
  • 1
  • 14
0
votes
1 answer

Passing an MLMultiArray (or CGImage) to PencilKit so it can be edited

Is it possible to initialize my PKCanvasView.drawing from an MLMultiArray or CGImage so that the user can edit it? I have a semantic segmentation model that outputs the MLMultiArray of 1s (detected) and 0s (not-detected). I want the user to be able…
stuvx
  • 1
  • 2
0
votes
1 answer

Cannot able to change PKToolpicker tools

I need to Draw over an image using PencilKit. the problem I face is I can't able to change the PencilKit tool picker tools (Eg pen to pencil). I am able to use only pen mode in the PKInkTool Posted my code below class ViewController:…
0
votes
1 answer

How to create new tools in PencilKit

By default, Apple gives us three inking tools: .pen, .pencil, and .marker. How can I create a new tool? Specifically, I need a ballpen tool that has a constant width. Apple has created new tools for PencilKit in their Freeform app, take a look: Or…
Stan
  • 77
  • 1
  • 7
0
votes
0 answers

PencilKit doesnt change

When I try to change color or tool nothing happens and it still drawing with deafult black pen. class ViewController: UIViewController { @IBOutlet weak var canvasView: PKCanvasView! override func viewDidLoad() { super.viewDidLoad() } override…
0
votes
2 answers

Strokes disappearing in SwiftUI PencilKit

I was really comfortable using PencilKit in SwiftUI, however I revisited a project and apparently there is a bug in Xcodes new version where strokes disappear after drawing them in the simulator. I am running Version 14.1 of Xcode. I set up a…
jakob witsch
  • 157
  • 1
  • 1
  • 12
0
votes
0 answers

how to configure the toggle method between finger touch and pencil in PencilKit after iOS 14.0?

I use this IBAction below but I get some errors. How can I make it work efficiently? @IBAction func fingerOrPencil (_ sender: Any) { canvasView.allowsFingerDrawing.toggle() pencilButton.title = canvasView.allowsFingerDrawing ?…
asduskun
  • 17
  • 5
0
votes
1 answer

pencil kit issue--drawing can't stay on canvas

I want to use pencil kit in my swiftui app. I encapsulate PKCanvasView in UIViewRepresentable. I can draw on canvas with only one stroke. However, the image will disappear immediately when I release the finger. Am I missing anything? import…
test1229
  • 125
  • 9
0
votes
2 answers

How to make PKStroke conform to Equatable?

In my app, I need to store a single PKStroke and then be able to find it in a canvasView.drawing.strokes array and modify it. If I'm correct, I need PKStroke to conform to Equatable protocol. I've found two ways of doing it: //1. extension PKStroke:…
Stan
  • 77
  • 1
  • 7
0
votes
2 answers

PKCanvas is not drawable as a subview of PDFKit OverlayView

I want to overlay pencil kit canvases automatically on PDFView with the new PDFKit OverlayProvider Protocol in iPad OS 16. I added PKCanvas view as a subview of OverlayView, which is UIView, for PDFKit. I succeed in displaying and deleting overlay…
Carl.H.L
  • 1
  • 1
0
votes
0 answers

How to clean PKCanvas from strokes when I leave the screen?

I have a basic app, a Main View with links to Drawing View. When I go to the Drawing View №1 and paint something with Apple Pencil, then go back to Main View, then go back to Drawing View №1 - I still see my painting. It stayed in the…
Stan
  • 77
  • 1
  • 7