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
5
votes
2 answers

Convert UIBezierPath to PKStrokePath swift

Is there a way to convert UIBezierPath to PKStrokePath ? for example I have these path as UIBezierPath how can I convert it to PKStrokePath to use it in PKDrawing ? let shape = UIBezierPath() shape.move(to: CGPoint(x: 30.2, y:…
Basel
  • 550
  • 8
  • 21
5
votes
1 answer

Force QLPreviewController into Edit mode on iOS13

Just presenting a QLPreviewController to view an image (on iOS13.) Ideally I'd like it to switch into edit mode automatically (and so present the PencilKit stuff.) Anyone know how to do this? The setEditing: approach (used on UITableViewControllers)…
Scotty
  • 2,019
  • 1
  • 20
  • 31
4
votes
0 answers

How to implement PencilKit in SwiftUI with background and zoom?

I am trying to build a view in SwiftUI that allows me to draw on top of another view, for example a table, using PencilKit. Everything must be zoomable and the elements of the background view must be clickable. I thought about using a ZStack: ZStack…
4
votes
0 answers

How to correctly resize PKDrawing when layout changes?

I'm trying to layer a PKCanvasView on top of an image, which works fine with the initial layout but when the view is resized (by rotating the iPad) the PKDrawing within is not scaled which results in the image annotations being in the incorrect…
ADB
  • 591
  • 7
  • 21
4
votes
1 answer

How to dismiss PKToolPicker when view disappears in SwiftUI?

I'm trying to wrap PKCanvasView as a SwiftUI view called CanvasView. I'd like to be able to toggle the whole canvas on top of another view. When the CanvasView appears, I'd like the PKToolPicker to appear. When it disappears, I'd like the…
ADB
  • 591
  • 7
  • 21
4
votes
2 answers

PKToolPicker color picker dark mode on iOS 14

I have a controller with a PKCanvasView that's connected to the window shared PKToolPicker. I can force the PKToolPicker to have a dark appearance (image 1) with: if let window = self.parent?.view.window, let toolPicker = PKToolPicker.shared(for:…
DaleOne
  • 233
  • 1
  • 8
4
votes
0 answers

PDFView with PKCanvasView drawingGestureRecognizer on iOS14

Minimum code to add a PKCanvasView to PDFView. The PKCanvasView displays properly if the PKDrawing is set. However on iOS14, the drawingGestureRecognizer does not fire. Works on iOS13 import UIKit import PDFKit import PencilKit class…
NewEndian
  • 559
  • 2
  • 16
4
votes
2 answers

Saving PencilKit image – SwiftUI

I have a SwiftUI view to capture a user signature using a UIViewRepresentable PencilKit view. The view is capturing the signature just fine, but when I try to save the signature, the file saved is a blank/empty PNG file. import PencilKit struct…
Dwillmore
  • 65
  • 1
  • 7
4
votes
2 answers

Editing PKDrawing in PencilKit

When using PencilKit in iOS 13/iPadOS, how do you change the content in PKDrawing? For example, can I go through all the lines and change the color or width of the lines? Or for selected lines (via lasso)? Or add a straight line in our own code?
Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88
3
votes
0 answers

Scrollable PKCanvasView with SwiftUI subview

I found this question on stackoverflow with this source code as possible solution. How can I use a SwiftUI view instead of a UIImageView as underlayView? I tried to replace the UIImageView with a UIView and converted my SwiftUI view with a…
halloduda
  • 31
  • 2
3
votes
1 answer

How do I create a PKDrawing programmatically, from CGPoints?

I've watched this WWDC session as well as its sample project: https://developer.apple.com/documentation/pencilkit/inspecting_modifying_and_constructing_pencilkit_drawings However, when I try to plot CGPoints on my drawing canvas, nothing shows…
Roger Oba
  • 1,292
  • 14
  • 28
3
votes
1 answer

PKToolPicker add text, shape and signature

I am not getting any option to add text, shape and signature while markup a photo with PencelKit in my app. This option is available in Apple's Photos App. I have tried to access this with various properties of CanvasView and PKToolPicker, but with…
dream
  • 31
  • 1
3
votes
0 answers

PencilKit clearing canvas not always working

I am building a PencilKit app that interprets a canvasView.drawing's size. Drawings below a certain size are interpreted as tap gestures and get cleared in the interpretation process. Effectively, I am doing it like this: func…
cmaltese
  • 41
  • 2
3
votes
0 answers

How can I modify PKStrokes before canvasViewDidEndUsingTool is called?

I'd like to implement something to straighten lines when the user holds the pencil in one place at the end of the stroke, however I don't have access to the PKStrokes to modify until they release the pencil from the iPad. Apple's version of this in…
David Peat
  • 244
  • 2
  • 5
3
votes
1 answer

Using PKToolPicker without PKCanvasView

I am trying to use PKToolPicker from PencilKit (iOS/Swift) from a custom view (which is NOT PKCanvasView). The custom view conforms to PKToolPickerObserver. Everything works fine during compile time but I never get to see the PKToolPicker! If I…
Arshia
  • 334
  • 2
  • 13
1
2
3
9 10