There is error when launch app which use Pencil kit
When I try with iOS15 simulator or Xcode editor preview it crashed
Here is error message
Library not loaded: /usr/lib/swift/libswiftPencilKit.dylibI
Reason: tried: '/Users/.../Products/Debug-iphonesimulator/libswiftPencilKit.dylib' (no such file)
There is no problem with iOS14.5 simulator
Post not yet marked as solved
I am working on an app that allow user to taking notes, and I want to support inline editing that means users can use PencilKit feature and edit text in a single note just like the Notes app.
Is there any good idea to achieve this using SwiftUI?
Post not yet marked as solved
I have done the same thing in SwiftUI using UIViewRepresentable, but toolPicker doesn't show so I checked isFirstResponder property and I found that it was still false after I called canvas.becomeFirstResponder().
Check this out:
struct NoteCanvasView: UIViewRepresentable {
func makeUIView(context: Context) -> PKCanvasView {
let canvas = PKCanvasView()
canvas.drawingPolicy = .anyInput
canvas.delegate = context.coordinator.self
let toolPicker = PKToolPicker()
toolPicker.setVisible(true, forFirstResponder: canvas)
toolPicker.addObserver(canvas)
print(canvas.canBecomeFirstResponder)
canvas.becomeFirstResponder()
print(canvas.isFirstResponder)
return canvas
}
func updateUIView(_ canvas: PKCanvasView, context: Context) {
canvas.becomeFirstResponder()
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject {
var parent: NoteCanvasView
init(_ parent: NoteCanvasView) {
self.parent = parent
}
}
}
I found canvas.canBecomeFirstResponder returns true and canvas.isFirstResponder always returns false.
Is this a bug in current version of SwiftUI??
Post not yet marked as solved
Hi ,
I was watching
https://developer.apple.com/videos/play/wwdc2020/10148/
And I did read the demo project code
but I don't understand how Apple know when write "W" in textfield it's "W" in drawing area ?
I understand that we separate every char from drawing data , but how it matching with the textfield text ?
this part it's confusing me
Post not yet marked as solved
Hy! Hope you are all doing well. I already ask this question but no one give me any solution. I saw video of Inspecting, Modifying, and Constructing PencilKit Drawings. This video clear my all concepts. But I've one issue I want to draw on numbers like alphabets but there is no numbers file. In this code only uppercase and lowercase drawing file but these files not open. Firstly kindly tell me how to open this file and how to draw on numbers like alphabets. Your solutions are appreciation for me. I am waiting for your solution. Thanks.
Post not yet marked as solved
I'm implementing swift UI image view overlaid by canvas view in Pencil kit
Because Pencil kit is in UIKit
I create another class for creating gesture recognizer
Thankfully it work so I can zoom or pan on canvas view and the underling image view is responding
But unlikely using Gesture and GestureState in SwiftUI
It cause memory issue when I just zoom image it take almost 1GB
Here is my code
class GestureDelegate: NSObject, ObservableObject, UIGestureRecognizerDelegate {
var zoomScale: CGFloat {
fixedZoomScale * gestureZoomScale
}
var fixedZoomScale: CGFloat = 1
@Published var gestureZoomScale: CGFloat = 1
private(set) lazy var pinchGestureRecognizer: UIPinchGestureRecognizer = {
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(pinchImage(_:)))
pinchGesture.delegate = self
return pinchGesture
}()
Here is canvas view in UIViewRepresentable
There is pan gesture recognizer also but there is no problem with pan gesture
struct BlurMaskView: UIViewRepresentable {
private let canvas: PKCanvasView
private let gestureDelegate: GestureDelegate
func makeUIView(context: Context) -> PKCanvasView {
canvas.drawingPolicy = .anyInput
canvas.tool = tool
canvas.backgroundColor = .clear
canvas.addGestureRecognizer(gestureDelegate.pinchGestureRecognizer)
canvas.addGestureRecognizer(gestureDelegate.panGestureRecognizer)
return canvas
}
Post not yet marked as solved
Hy!
Hope you are all doing well. I saw video of Inspecting, Modifying, and Constructing PencilKit Drawings. This video clear my all concepts. But I've one issue I want to draw on numbers like alphabets but there is no numbers file. In this code only uppercase and lowercase drawing file but these files not open. Firstly kindly tell me how to open this file and how to draw on numbers like alphabets.
Your solutions are appreciation for me.
I am waiting for your solution.
Thanks.
Post not yet marked as solved
on iOS, I want to add up undo/redo and a close button. On ipadOS, I only need to add a close button
What’s your experience in adding a close button to the ToolPicker? Or at least have the position of the window so I can add an overlapping box (even on floating).
Post not yet marked as solved
Hy! I saw your video Inspect, modify, and construct PencilKit drawings. Literally it is amazing I've a question in that we can drawing only by apple pencil but i want to draw by fingers can you tell me how it is possible. I shall be very grateful to you.
Thanks