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

Adding text and images to PencilKit Canvas

I'm trying to create a clone of the native iOS Notes app. I already have a PencilKit setup with SwiftUI. I'm now trying to add (typed) text to the note and background images/patterns. I also want to serialize the notes to a file. How do I add…
Benedikt Bergenthal
  • 495
  • 1
  • 7
  • 20
2
votes
2 answers

How to determine if PKDrawing is blank?

I am using PencilKit in my app and let my users draw images on PKCanvasView. But I don't want them to be able to save blank drawings. So I need to check if PKDrawing is blank (doesn't contain anything besides transparent pixels). I couldn't find any…
SmartTree
  • 1,381
  • 3
  • 21
  • 40
2
votes
2 answers

Can I use apple libraries like CoreML and PencilKit with react-native apps?

I really want to make use of the pencil kit in my react-native application. I just want to know whether I can do it. If yes, then how?
Ashutosh
  • 41
  • 1
  • 5
2
votes
1 answer

Setting PKCanvasView to draw on image and save it

Situation In my iOS app, I have a feature where I can take a picture and then, draw on it. I currently use an old Cocoapods library and I would like to switch to PencilKit. Problem Documentation and online tutorial are very unclear on the…
Maxime Lapointe
  • 193
  • 1
  • 5
2
votes
2 answers

Set pencilkit canvas to be the input image size and prevent drawing outside that region Swiftui

How to prevent drawing outside the scaled aspect ratio image background? I need to draw on images, similar to markup, and based on what I've seen, you have to add an image to the background of a PKCanvasView. In the SO below, I more or less did the…
NeedHelp101
  • 599
  • 1
  • 9
  • 25
2
votes
1 answer

Predefined Shapes using UIPencilKit

I'm creating a drawing app using UIPencilKit, I also need to draw some pre-defined shapes like straight line, circle, rectangle, arrow etc. by selecting a shape from list and draw it on canvas automatically. Any help how to achieve it? Thanks In…
2
votes
1 answer

How to modify individual strokes in PKDrawing? - PencilKit / SwiftUI

I'd like to change the colors of individual strokes in a drawing. Printing PKDrawing().strokes returns an array with multiple PencilKit.PKStroke items and I can remove strokes from the array which reflects on the canvas. However, if I wanted to…
gelato18
  • 49
  • 8
2
votes
2 answers

Background Image and canvas with pencilKit Swiftui

I'm learning about PencilKit. I have a canvas, and I want to set a background image that we can draw on it. When I save my canvas, I want my background image to be visible But I have an error : Cannot convert value of type 'Image' to expected…
Clément Tengip
  • 618
  • 6
  • 19
2
votes
0 answers

Excessive dirty memory

I'm developing an iOS app for drawing on a simple canvas. The app manages one canvas per time (layers are managed differently). I didn't use 3rd party libraries and all components are Apple friendly (canvas is PencilKit for example) while the UI is…
Oscar053
  • 31
  • 2
2
votes
2 answers

About iOS14 of PencilKit

environment ・MacOS: 10.15.7 ・Xcode: 12.1 ・iOS: 14.1 I am trying to PencilKit and but I cannot show PKToolPicker. I set my code as below: if let window = UIApplication.shared.windows.first { if let toolPicker = PKToolPicker.shared(for: window)…
2
votes
1 answer

PKDrawing: Text to PKStroke

I would like to add text to a PKDrawing Apple actually demonstrates this use case in their WWDC2020 video: https://developer.apple.com/videos/play/wwdc2020/10148 However, looking at the sample code, they simply recorded previously drawn text Anyone…
NewEndian
  • 559
  • 2
  • 16
2
votes
1 answer

PKToolPicker from PencilKit does not show on programmatically created UIWindow

I have a view controller that wants to show a PKCanvasView and a PKToolPicker from PencilKit. Here's the code: import UIKit import PencilKit class ViewController: UIViewController { @IBOutlet weak var canvas: PKCanvasView! override func…
2
votes
5 answers

Implement PencilKit undo functionality using SwiftUI

Edit: Thanks to some of the feedback, I have been able to get this partially working (updated code to reflect current changes). Even though the app appears to be working as intended, I am still getting the 'Modifying state...' warning. How can I…
PointOfNilReturn
  • 416
  • 4
  • 13
2
votes
1 answer

iOS PencilKit not drawing

I am trying to PencilKit and but I cannot draw anything in the app. I set my code as below. import UIKit import PencilKit class DrawingViewController: UIViewController { var canvasView: PKCanvasView! override func viewDidLoad() { …
eemrah
  • 1,603
  • 3
  • 19
  • 37
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