Skip to content

Instantly share code, notes, and snippets.

@almaleh
Created January 16, 2019 04:52
Show Gist options
  • Save almaleh/3a680c9b9e1b25cb5a849d03096ea06a to your computer and use it in GitHub Desktop.
Save almaleh/3a680c9b9e1b25cb5a849d03096ea06a to your computer and use it in GitHub Desktop.
override func draw(_ rect: CGRect) {
super.draw(rect)
guard let context = UIGraphicsGetCurrentContext() else { return }
// draw the flattened image if it exists
if let image = flattenedImage {
image.draw(in: self.bounds)
}
context.setStrokeColor(lineColor.cgColor)
context.setLineWidth(lineWidth)
context.setLineCap(.round)
for (index, point) in line.enumerated() {
if index == 0 {
context.move(to: point)
} else {
context.addLine(to: point)
}
}
context.strokePath()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment