Reputation: 610
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??
Upvotes: 9
Views: 7430
Reputation: 53551
You can use CGPathCreateCopyByTransformingPath
which creates a copy of your path, transformed by a given CGAffineTransform
. There's also CGPathCreateMutableCopyByTransformingPath
for 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 with CGPathAddPath
which optionally takes a transformation as its second parameter.
Upvotes: 17