What I am trying to do is to apply a CGAffineTransform to a CGPath.
I know, if I were drawing onto a CGContext, I would just transform the context itself.
But what I want to do is to apply a transform to the actual path itself. UIBezierPath allows me do to this with the applyTransform: method, it doesn’t transform it’s CGPath.
Is there any way to apply a CGAffineTransform to a CGPath itself??
You can use
CGPathCreateCopyByTransformingPathwhich creates a copy of your path, transformed by a givenCGAffineTransform. There’s alsoCGPathCreateMutableCopyByTransformingPathfor creating a mutable copy.Note that both of these functions have been introduced in iOS 5.
If you need something that works on earlier versions of iOS, you could create an empty path (
CGPathCreateMutable) and add your other path withCGPathAddPathwhich optionally takes a transformation as its second parameter.