wbarksdale wbarksdale - 1 year ago 63
Objective-C Question

How can I mirror a UIBezierPath?

I have a

UIBezierPath
and I would like to get its mirror image. How can I accomplish this?

// Method for generating a path
UIBezierPath *myPath = [self generateAPathInBounds:boundingRect];

// ? now I would like to mirror myPath ?

Answer Source
// Method for generating a path
UIBezierPath *myPath = [self generateAPathInBounds:boundingRect];

// Create two transforms, one to mirror across the x axis, and one to
// to translate the resulting path back into the desired boundingRect
CGAffineTransform mirrorOverXOrigin = CGAffineTransformMakeScale(-1.0f, 1.0f);
CGAffineTransform translate = CGAffineTransformMakeTranslation(boundingRect.width, 0);

// Apply these transforms to the path
[myPath applyTransform:mirrorOverXOrigin];
[myPath applyTransform:translate];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download