How to draw a BezierPath on a button tap?
I'm practicing with BezierPaths
. What I'm trying to do is draw a BezierPaths
shape when a button is tapped but I'm not seeing anything on the screen when I tap the button. I'm not getting any errors just the output in the debug area shown below.
What am I missing?
Here is my code:
@IBAction func drawIt(_ sender: Any) {
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 46.5, y: 50.14))
bezierPath.addCurve(to: CGPoint(x: 77.5, y: 50.5), controlPoint1: CGPoint(x: 46.5, y: 50.14), controlPoint2: CGPoint(x: 64.74, y: 34.09))
bezierPath.addCurve(to: CGPoint(x: 94.5, y: 96.5), controlPoint1: CGPoint(x: 84.5, y: 59.5), controlPoint2: CGPoint(x: 88.29, y: 74.25))
UIColor.black.setStroke()
bezierPath.lineWidth = 1
bezierPath.stroke()
}
Debug Area:
CGContextSetStrokeColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.