Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Created Jun 16, 2020
Embed
What would you like to do?
Cuphead-HeadShape
private func getHeadShape() -> CAShapeLayer {
let path = UIBezierPath()
path.move(to: CGPoint(x: 84, y: 196)) //Set StartPoint for QuadCurve
path.addQuadCurve(to: CGPoint(x: 366, y: 100), //Add EndPoint QuadCurve and StartPoint for Curve
controlPoint: CGPoint(x: 205, y: 100))
path.addCurve(to: CGPoint(x: 84, y: 196), //Add EndPoint for Curve
controlPoint1: CGPoint(x: 500, y: 330),
controlPoint2: CGPoint(x: 120, y: 430))
path.close() //Connect first point and last point of bezier path
let headShape = CAShapeLayer()
headShape.path = path.cgPath
headShape.lineWidth = 5
headShape.strokeColor = UIColor.black.cgColor //Color of stroke
headShape.fillColor = UIColor.clear.cgColor //Color of fill. We need an empty fill here
return headShape
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment