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

How to disable pencil drawing in PKCanvasView of PencilKit, just for viewing purpose

I successfully created PKCanvasView in my view and make it work to draw in there. But how to disable drawing in PKCanvasView for some purposes like viewing mode only. Is it possible to disable drawing with both pencil and finger in PKCanvasView? I…
2
votes
2 answers

Setting eraser type to bitmap for PencilKit (iOS)

Using PencilKit for iOS, how do I set the eraser tool to .bitmap for PKToolPicker? I can't find any setting for PKToolPicker. Trying to use PKCanvasView to observe and set the tool's eraserType as .bitmap also does not work. override func…
Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88
2
votes
1 answer

Supporting lower OS version for PencilKit

So we have an app, it's minimum target is iOS11. We have introduced Pencil kit (iOS13 only). So need to support both iOS11 and 13. The app will compile and run as long as we use stored properties in functions. However when we use new variables in…
t.ios
  • 1,024
  • 12
  • 18
2
votes
2 answers

Why does PKDrawing() != PKDrawing()? (PencilKit)

According to the docs, PKDrawing conforms to Equatable. But if you compare 2 blank drawings with ==, it returns false. I submitted a bug via the feedback app, but I am posting here hoping I missed something or others will also submit a bug report…
hidden-username
  • 2,610
  • 3
  • 14
  • 19
2
votes
3 answers

PencilKit - ITMS-90338: Non-public API usage when uploading app to AppStoreConnect

I tried weak linking PencilKit in 3 different ways: Via target > Frameworks > Add PencilKit > Do Not Embed By weak linking using "-weak_framework PencilKit" in other linker flags By linking using "-framework PencilKit" in other linker flags Each…
Dev Sanghani
  • 1,145
  • 11
  • 19
2
votes
2 answers

How to annotate pdfs with the new pencilkit api?

I would like to know how to edit a pdf using apples new Pencilkit API. You could put a pdf underneath the PKCanvasView but this would not really change the PDF itself only my pkcanvasView. Any ideas or examples?
Tupular
  • 21
  • 5
2
votes
1 answer

Removing content in PencilKit

When using PencilKit in iOS 13/iPadOS, how do you remove all content from the screen, or remove those content selected (via lasso)? I can't find any functions in PKDrawing or PKCanvasView that do these?
Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88
1
vote
1 answer

Can't load/decode PKDrawing using any of the new inks (version 2, iOS 17)

I am using Xcode 15 beta 5 with iOS 17 beta 4 SDK. By building with the iOS 17 SDK my app got all the new inks which work great. Saving/encoding the PKDrawing to Data also works fine. However if I want to load the same PKDrawing again, on the same…
mbuchetics
  • 1,370
  • 1
  • 17
  • 34
1
vote
0 answers

How can I prevent my PKCanvas PDFOverlay object from becoming blurry when pinch-zooming in on a PDF in iOS?

I got the code presented in WWDC2021 to work and im able to overlay a PencilKit Canvas object over each pdf page. When starting the app, a pdf is shown and the overlayed PKCanvas looks as expected. When pinch-zooming in on the pdf, the PKCanvas gets…
1
vote
0 answers

What is a proper way to scale PKCanvasView (UIScrollView)

I have PKCanvasView in my iPad app. When the user rotates the iPad - I need to scale the Canvas and all the strokes accordingly. So far I've found two ways to scale a PKCanvasView, first with a .zoomScale: GeometryReader { geo in // Canvas View goes…
Stan
  • 77
  • 1
  • 7
1
vote
0 answers

Change PKStroke position in PencilKit

I currently try to implement my own lasso tool in Swift in order to change the position of my Strokes drawn on a Pencil Kit Canvas. I select strokes by storing the indices of the strokes that are inside my drawn Rect. func select(rect: CGRect) { …
jakob witsch
  • 157
  • 1
  • 1
  • 12
1
vote
2 answers

Swiftui UIViewRepresentable - How to update PKCanvasView image when imageData source is changed on user action

I am creating a SwiftUI app with PencilKit & UIViewRepresentable. I am adding a image coming from server on top of the PKCanvasView. Code works fine when I click on a image and open a canvas view then close it and reopen it. But I am not able load a…
1
vote
2 answers

I can't use different colors or rubber in PencilKit

Why can't I use other pencils or colors as expected in this app? It only draws a black color. This is my code: import UIKit import PencilKit import PhotosUI ​ class ViewController: UIViewController, PKCanvasViewDelegate, PKToolPickerObserver { ​ …
asduskun
  • 17
  • 5
1
vote
0 answers

PencilKit '.monoline' as a PKInkingTool.InkType suddenly doesn't work anymore

I am writing a program using PencilKit. Yesterday, everything worked fine with this line: @State var pencilStyle: PKInkingTool.InkType = .monoline But today, i am getting this Error: Type 'PKInkingTool.InkType' has no member 'monoline'" When I…
yama_HD
  • 480
  • 1
  • 4
  • 14
1
vote
0 answers

Color intensity increases when converting PKDrawing data to uiimage

I am trying to convert PKDrawing data to uiimage. Thus I've used apple's API PKDrawing data to uiimage. But the colour intensity of the converted image increases surprisingly. I mean there is a difference between the canvas data and the converted…
Rabel Ahmed
  • 1,131
  • 13
  • 12