For the following lightning bolt graphic:
I'm trying to flip it while scaling like such:
CGAffineTransform transform = CGAffineTransformMakeScale(newSize.width / initialSize.width, -1 * (newSize.height / initialSize.height));
CGMutablePathRef mutablePath = CGPathCreateMutableCopyByTransformingPath(shapeLayer.path, &transform);
shapeLayer.path = mutablePath;
CGPathRelease(mutablePath);
This is what happens:
I've tried a bunch of different ways to translate it but to no success:
CGAffineTransform transform = CGAffineTransformMakeTranslation(newSize.width / 2, newSize.height / 2);
transform = CGAffineTransformScale(transform, newSize.width / initialSize.width, -1 * (newSize.height / initialSize.height));
transform = CGAffineTransformTranslate(transform, -newSize.width / 2, -newSize.height / 2);
Does anyone know the correct way to get my graphic back into the bounding box of the view?
Matt's response pushed me in the right direction and this is ultimately how I was able to solve the problem:
CGAffineTransform transform = CGAffineTransformMakeScale(newSize.width / initialSize.width, newSize.height / initialSize.height);
if (flipped)
{
transform = CGAffineTransformTranslate(transform, 0, initialSize.height / 2.0);
transform = CGAffineTransformScale(transform, 1, -1);
transform = CGAffineTransformTranslate(transform, 0, -initialSize.height / 2.0);
}