Skip to content

Instantly share code, notes, and snippets.

@swhitty
Created February 27, 2017 11:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swhitty/12d303a64db0ca72790a7f59fb515123 to your computer and use it in GitHub Desktop.
Save swhitty/12d303a64db0ca72790a7f59fb515123 to your computer and use it in GitHub Desktop.
Bridges CoreGraphics.CGPathApplierFunction with a standard Swift closure
extension CGPath {
func apply(action: @escaping (CGPathElement)->()) {
var action = action
apply(info: &action) {
let action = $0!.bindMemory(to: ((CGPathElement)->()).self, capacity: 1).pointee
action($1.pointee)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment