Questions tagged [apple-pencil]
30 questions
11
votes
0 answers
Initial position for PKToolPicker (PencilKit)?
How to setup PKToolPicker initial position?
It always started at the bottom, and if there is a toolbar, cover up the toolbar.
let toolPicker = PKToolPicker.shared(for: self.view.window!)
toolPicker?.addObserver(canvas)
toolPicker?.setVisible(true,…

Lim Thye Chean
- 8,704
- 9
- 49
- 88
9
votes
2 answers
iOS PencilKit Draw shapes programmatically
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…

Santiago Carmona González
- 1,019
- 1
- 8
- 19
7
votes
4 answers
Is there any ways to handle and/or distinguish Apple Pencil and direct touches in SwiftUI?
I am wondering if there is a way to handle Apple Pencil events in SwiftUI? For example if you like to handle direct touches, and Apple Pencil differently, say direct touch to scroll, but Apple Pencil to draw lines.
There is a similar type of…

Kaz Yoshikawa
- 1,577
- 1
- 18
- 26
7
votes
2 answers
How to differentiate whether a user is tapping the screen with his finger or an apple pencil?
The App supports iPad Pro and it has to work with the Apple Pencil. What I would like to do is to differentiate whether the user is using the Apple Pencil or his finger.
Something like:
if( the user is pressing the screen with his finger){
do…

Kokodelo
- 416
- 1
- 5
- 25
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…

Pierluca Lippi
- 41
- 2
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
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
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…

Alvaro Sanz Rodrigo
- 21
- 3
2
votes
0 answers
Detect Apple Pencil 2 double tap in browser
Apple Pencil 2 now supports a double-tap near the tip of the pencil to perform auxiliary functions in supported apps.
Is there any way to detect this double-tap in a browser?
It doesn't seem to trigger any of the usual event suspects (click,…

nicholaswmin
- 21,686
- 15
- 91
- 167
2
votes
0 answers
Matching Apple Pencil Input to Arbitrary Symbols
I'm planning on creating an app that allows you to hand-draw circuits using the apple pencil. The symbols you draw will then be recognised and converted into a nice diagram.
I've had a look through the Apple Pencil SDK docs and I can't seem to see…

ScottishTapWater
- 3,656
- 4
- 38
- 81
2
votes
1 answer
Using PencilKit in Swift. What is the best way to save PKDrawing into a database? How to serialize it?
I’m working in a App using Swift that includes PencilKit with a “canvasview” to take notes. Everything works fine, but I can’t find the way to “convert” de value returned by canvasView.drawing to String for uploaded it and storage into a…

oscarabilleira
- 121
- 1
- 12
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
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
1 answer
Nil cannot be assigned to type 'Timer'?
Hi there I am completing some research for Alzheimers Disease - I want to be able to record the time it takes to complete a drawing (it should only take a few seconds for the patient to draw). I want to record both the time spent with apple pencil…

Richard Buckley
- 23
- 6
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