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

Finger and Pencil width on PKCanvasView Different

I am trying to build out an application with the ability to use both apple pencil and finger input to draw. However, when I set the width of the tool to a sufficiently small number (1) the pencil input displays correctly, but when I use my finger it…
balt2
  • 75
  • 5
3
votes
0 answers

PKCanvasView How to get position and pressure in iOS 13 [objC]?

i want to get data of each point position and pressure which have been painted in PKCanvasView, i have tried touchesBegan with kept user interaction enabled and gesture Recognisers but none of it worked for me. If there is any other solution to…
rathodbhavikk
  • 416
  • 7
  • 20
3
votes
3 answers

PencilKit unable to simultaneously satisfy constraints

I am trying to implement pencil kit toolkit (a bar of pencil, eraser, etc.) that appears at the bottom of the screen. However, upon running this line of code: guard let window = view.window, let toolPicker = PKToolPicker.shared(for: window) else…
user65909
  • 101
  • 1
  • 9
2
votes
0 answers

Pencil drawing and finger gesture unable to be recognized simultaneously SwiftUI

in a project we are working on using SwiftUI and PencilKit we are required to create a button that while being tapped, changes the PKInkingTool of the PKCanvasView we are using. PencilKit uses UIKit so we have it enclosed in a UIViewRepresentable…
2
votes
2 answers

How to make PKCanvasView float/pan in the middle of a fixed background?

In a canvasview setup, I was not able to create a pannable white background canvas on top of a grey background. See the behaviour desired: https://i.stack.imgur.com/fYyCW.jpg import SwiftUI import PencilKit struct ContentView: View { var body:…
erotsppa
  • 14,248
  • 33
  • 123
  • 181
2
votes
1 answer

How to make PKCanvasView zoomable in SwiftUI?

There a PKCanvasView setup like this: struct CanvasView { @Binding var canvasView: PKCanvasView let onSaved: () -> Void @State var toolPicker = PKToolPicker() } extension CanvasView: UIViewRepresentable { func makeUIView(context: Context)…
erotsppa
  • 14,248
  • 33
  • 123
  • 181
2
votes
1 answer

PKCanvasView shape recognition

How to add shapeRecognition to PKCanvasView? looks like the SDK doesn't support that, are there alternatives?
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
2
votes
0 answers

Missing defaults dictionary to restore state for: PKPaletteNamedDefaults

[ToolPicker] Missing defaults dictionary to restore state for: PKPaletteNamedDefaults warning is outputted on my screen. I am looking to resolve this error and have found that if I don't make the following call, I do not get an error. What am I…
Pangur Ban
  • 21
  • 1
2
votes
1 answer

PDFKit - PDFPageOverlayViewProvider with PKCanvasView is not forwarding Touch events - WWDC22 Session 10089

I am trying to utilize the PDFPageOverlayViewProvider protocol of the PDFView class in the PDFKit framework introduced with iOS 16 in order to display a PencilKit PKCanvasView on top of a PDF document so that the user can draw stuff on the PDF. What…
larsschwegmann
  • 725
  • 1
  • 6
  • 14
2
votes
1 answer

How to ignore specific events so it passes to view below in a ZStack?

I'm developing a small PencilKit app and have placed a UIViewRepresentable on top of it in a ZStack to handle gesture input (to rotate, scale and pan the canvas around the screen). But I'm struggling to get that top view to ignore PencilKit input…
CodeyTown
  • 87
  • 4
2
votes
0 answers

Why does PKToolPicker disappear when blur and doesn't come back

When using PKCanvasView and PKToolPicker in a SwiftUI project using Xcode 13, the PKToolPicker disappear when I blur the view, and it doesn't come back when I remove the blur effect. I am trying to create a popup (to add some setting to the view),…
2
votes
0 answers

Store Drawings of PKCanvasView in file

I created a document based app with SwiftUI and a PKCanvasView. Now I want to save the drawings of the PKCanvasView inside of the file. How can I do this?
2
votes
1 answer

Apple Pencil pen color is darker than the color given to PKInkingTool

I've got the bare minimum apple pencil setup: a PKCanvasView named 'drawingView' given an inking tool as follows (to set the starting pen color): let penColor = UIColor.white.withAlphaComponent(0.5) drawingView.tool = PKInkingTool(.pen, color:…
2
votes
0 answers

"Drawing count mismatch!" error in PencilKit canvasViewDidEndUsingTool delegate

I'm trying to put together a simple drawing app using PencilKit. However, when I zoom in on the canvas, I'd like the stroke to be thinner (visually the same size on the screen as it was before zooming in, but once I zoom all the way out, the result…
Roger Oba
  • 1,292
  • 14
  • 28
2
votes
0 answers

Allow interaction with view behind depending on UITouch.TouchType using point(inside:with:). (PKCanvasView)

The problem I am trying to intercept touches on a view using the following logic: Determine whether UITouch.TouchType is .pencil If not .pencil, pass touches through to view below Else if .pencil, handle touch. (UIGestureRecognizer) My…
santi.gs
  • 514
  • 3
  • 15
1 2
3
9 10