Skip to content

Instantly share code, notes, and snippets.

@wokalski
Created March 25, 2016 20:46
Show Gist options
  • Save wokalski/53daff651bec92d51fda to your computer and use it in GitHub Desktop.
Save wokalski/53daff651bec92d51fda to your computer and use it in GitHub Desktop.
Create a CAShapeLayer with a UIBezierPath
extension UIBezierPath {
func shapeLayer() -> CAShapeLayer {
let l = CAShapeLayer()
let path = self.copy()
let bounds = path.bounds
let origin = bounds.origin
path.applyTransform(CGAffineTransformMakeTranslation(-origin.x, -origin.y))
l.path = path.CGPath
l.frame = bounds
return l
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment