I want to transform a CGPath with the transform CGAffineTransformMakeRotation(radians) but the CGPathCreateCopyByTransformingPath func takes a CConstPointer<CGAffineTransform>. How do I get a CConstPointer<CGAffineTransform> out of my CGAffineTransform?
Asked
Active
Viewed 1,002 times
2
JuJoDi
- 14,627
- 23
- 80
- 126
1 Answers
8
Pass the CGAffineTransform as an inout expression (that is, prefix it with &).
var xform = CGAffineTransformMakeRotation(3)
let newPath = CGPathCreateCopyByTransformingPath(originalPath, &xform)
Note that the transform must be a variable, not a Swift constant (declared with let).
c.f. Using Swift with Cocoa and Objective-C: Interacting with C APIs
jatoben
- 3,079
- 15
- 12