Skip to content

Instantly share code, notes, and snippets.

@akio0911
Last active November 27, 2020 13:16
Show Gist options
  • Save akio0911/1fac5d9711b028d826f30833185f77c3 to your computer and use it in GitHub Desktop.
Save akio0911/1fac5d9711b028d826f30833185f77c3 to your computer and use it in GitHub Desktop.
import UIKit
import PencilKit
class ViewController: UIViewController {
@IBOutlet weak var canvasView: PKCanvasView!
private let toolPicker = PKToolPicker()
override func viewDidLoad() {
super.viewDidLoad()
canvasView.drawingPolicy = .anyInput
canvasView.tool = PKInkingTool(.pen, color: .black, width: 30)
toolPicker.addObserver(canvasView)
toolPicker.setVisible(true, forFirstResponder: canvasView)
canvasView.becomeFirstResponder()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment