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
1
vote
1 answer

Convert Data into UnsafeRawPointer and vice versa in swift

I have been working on an app that uses Pencil Kit and I am trying to store a drawing on the canvas into a sqlite3 database. In order to do so, I had to convert the drawing(type: Data) into an UnsafeRawPointer. However, after the conversion, when I…
Clare
  • 71
  • 6
1
vote
0 answers

Clear undo buffer for PKCanvasView

I'm experimenting with Apple's PencilKit. Showing the PKToolPicker works well and I can draw into my canvas. However, I wondered whether and if so, how it is possible to clear the undo buffer. Background: I'm allowing the user to flip through his…
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
1
vote
0 answers

How to disable PKCanvasView from scrolling when selecting a drawing with lasso and moving it around

I think the title explains it pretty clearly. I have a PKCanvasView which is partially zoomed in, and when I select a part of the drawing with the lasso tool and then move it around with my pencil, the whole view starts shifting around following my…
Hamster
  • 133
  • 3
  • 12
1
vote
1 answer

How to use ZStack in UIKit

This is my SwiftUI code, it works fine. user can draw and pres button with no problem. i want user draws on anything, labels, buttons etc. But how can i do this with UIKit ? any idea ? (i edited Kavsoft's code pencilkit for swiftui:…
Yavuz Tarhan
  • 546
  • 5
  • 12
1
vote
1 answer

PencilKit toolPicker is not showing up

I am trying to create an app using PencilKit. I have the following code in one of my ViewControllers. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) guard let window = view.window, let…
1
vote
3 answers

Get bounds of PKDrawing / individual strokes in PencilKit

I need access to the coordinates of individual strokes of a PKDrawing in PencilKit. Is there any way I can get access to that? Currently, my only idea is to try and decode the opaque data representation we get from PKDrawing.
1
vote
1 answer

How to create .drawing file for PencilKit?

If you look at Apple's PencilKit Sample, you'll noticed apple used a dataset file called Notes.dataset to save Pencilkit draws. Inside the Notes.dataset, it contains a general json file for Asset Catalogue. But more interesting, there is a file…
Legolas Wang
  • 1,951
  • 1
  • 13
  • 26
1
vote
2 answers

PencilKit in SwiftUI

I'm trying to use PencilKit in SwiftUI. How can I detect in the updateUIView-function, which Binding-variable was updated? For example I don't want to clear the canvas when changing the color. And is there a better way to clear the canvas than…
simibac
  • 7,672
  • 3
  • 36
  • 48
1
vote
0 answers

Creating a Note Editor with Apple Pencil functionality?

Does anyone know how to make Apple Pencil work well in the context of a UITextView? For example, using the Apple Pencil with TextKit to create a 'drawing space' that expands as the user draws more within the UITextView. Just like in the Notes app. I…
AppreciateIt
  • 696
  • 2
  • 8
  • 23
0
votes
1 answer

Select CanvasView tools over many files

I have four files. In PKCanvasRepresentation.swift I only initialise the canvas view. In CanvasView.swift I use the initialisation and want to assign the individual tools through the given selection from NoteToolbarView.swift. In NoteToolbarView I…
Joschi
  • 13
  • 3
0
votes
0 answers

What is the correct way to save a PencilKit drawing to Core Data

There isn't a lot of information on PencilKit even less on saving PKDrawings to Core Data. But the ones that touch that subject usually turn PKDrawing into Binary Data and save it. I've found out that PKDrawingReference conforms to NSSecureCoding,…
Oliver
  • 83
  • 5
0
votes
0 answers

Is there some Library for Android like Pencil Kit of iOS?

I need to make an App for android and iOS. The App is for handwriting and drawing on PDF files. Yes, it is like Good note which is the famous App. I'm looking for some of SDK or library for developing this App. I think that the Pencil Kit for iOS…
Andy
  • 1
0
votes
0 answers

How to update drawing based on an array with core data

I have a Core Data Project that has 2 entities Drawing (one to many relationship with Frame) Frame - has an attribute called canvasDrawing that holds data of a PKDrawing. When I am trying to switch frames (because this is an animation app): 1st,…
anish1
  • 27
  • 6
0
votes
0 answers

How to change PKCanvas view based on CoreData

I have this view here: struct DrawingView: View { @Environment(\.managedObjectContext) var moc // Drawing @Binding var canvasView: PKCanvasView @State private var selectedBrushIndex = 0 @State private var isErasing = false …
anish1
  • 27
  • 6
0
votes
0 answers

Prevent PKCanvasView background from turning white while drawing

I have a PKCanvasView in my SwiftUI app using a UIViewRepresentable. I want the canvas content (PKDrawing) to have a white background and the rest of the view a gray background. The canvas is zoomable. Here is the relevant bits of my code: import…
alionthego
  • 8,508
  • 9
  • 52
  • 125