Skip to content

Instantly share code, notes, and snippets.

@almaleh
Last active January 19, 2019 22:19
Show Gist options
  • Save almaleh/d729a94615b2e814864c691333e297f0 to your computer and use it in GitHub Desktop.
Save almaleh/d729a94615b2e814864c691333e297f0 to your computer and use it in GitHub Desktop.
func updateFlattenedLayer() {
// 1
guard let drawingLayer = drawingLayer,
// 2
let optionalDrawing = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(
NSKeyedArchiver.archivedData(withRootObject: drawingLayer, requiringSecureCoding: false))
as? CAShapeLayer,
// 3
let newDrawing = optionalDrawing else { return }
// 4
self.layer.addSublayer(newDrawing)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment