Component - Canvas for drawing
This component provides a simple canvas where users can draw by touching and dragging their finger on the screen. It captures touch movements and renders lines following the finger path.
This component provides a simple canvas where users can draw by touching and dragging their finger on the screen. It captures touch movements and renders lines following the finger path.
UIView
└── DrawingView
├── CAShapeLayer
└── Gesture Recognizeroverride func draw(_ rect: CGRect) {
guard let ctx = UIGraphicsGetCurrentContext() else { return }
ctx.setFillColor(UIColor.red.cgColor)
ctx.fill(CGRect(x: 10, y: 10, width: 100, height: 50))
}override func draw(_ rect: CGRect) {
let ctx = UIGraphicsGetCurrentContext()
ctx.setFillColor(UIColor.blue.cgColor)
ctx.fillEllipse(in: CGRect(x: 20, y: 20, width: 80, height: 80))
}Pass the test and this pattern moves unknown