Applying CGAffineTransform to CGPath

What I'm trying to do is apply CGAffineTransform to CGPath.

I know that if I were drawing on a CGContext, I would just convert the context itself.

But I want to apply the conversion to the actual path itself. UIBezierPath allows me to do this using the applyTransform method: it does not convert it to CGPath.

Is there a way to apply CGAffineTransform to CGPath itself ??

+6
source share
1 answer

You can use CGPathCreateCopyByTransformingPath , which creates a copy of your path converted by this CGAffineTransform . There is also a CGPathCreateMutableCopyByTransformingPath for creating a mutable copy.

Please note that both of these features were introduced in iOS 5.

If you need something that works in earlier versions of iOS, you can create an empty path ( CGPathCreateMutable ) and add your other path using CGPathAddPath , which optionally takes the transformation as the second parameter.

+13
source

Source: https://habr.com/ru/post/903978/


All Articles