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() {
super.viewDidLoad()
let canvasView = PKCanvasView(frame: view.bounds)
canvasView.allowsFingerDrawing = false
view.addSubview(canvasView)
canvasView.translatesAutoresizingMaskIntoConstraints = false
canvasView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
canvasView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
canvasView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
canvasView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
canvasView.backgroundColor = UIColor.lightGray
canvasView.tool = PKInkingTool(.pen, color: .black, width: 10)
}
}
I am expecting to draw / inking in the canvasView but there's no response when I try the app. My device is running in 13.2 so there's no problem with the target. I've also downloaded the Apple's app from WWDC 2019 session but it's not working in the simulator. For clarify I've also tested it in real device but not respond in any application with PencilKit.