paint-project component adds a toolbar that allows you to draw notes or simple sketches within your application.
//Create your canvas
private lazy var paintView: DrawingView = {
$0.backgroundColor = .gray
$0.uiDelegate = self
$0.showToolPanel = false
return $0
}(DrawingView())
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(paintView) //Add paintView to your view
}
//Delegate for init
extension ViewController: DrawingViewDelegate {
func presentViewController() -> UIViewController {
return self
}
func rectForToolPanel() -> CGRect {
return CGRect(x: 50, y: 150, width: 300, height: 100)
}
Set custom canvas frame size
var rect = CGRect(x: 0, y: 0, width: 200, height: 200)
paintView.setRect(rect: rect)
Access to undo and redo is as follows
paintView.undo()
paintView.redo()
If you want to clear the screen
paintView.clean()
Save your masterpiece
paintView.save()