I'm running into some difficulty when rotating and then scaling an image later on. I can successfully move and rotate the UIImageView using this code:
myImage.center = CGPointMake(240 - (myImage.center.x - 240), myImage.center.y);
myImage.transform = CGAffineTransformMakeRotation(240 * M_PI开发者_Go百科 / 180);
But in another part of the code, I have the image scale larger:
CGAffineTransform transform = CGAffineTransformMakeScale(1.03,1.03);
myImage.transform=transform;
The problem is that when the image scales larger, the rotation goes back to the original.
Any ideas on how I can keep the rotation when I scale the UIImageView larger?
Thanks
The second time you're setting the transform you are overwriting the previous value. To fix this, change:
CGAffineTransform transform = CGAffineTransformMakeScale(1.03,1.03);
myImage.transform=transform;
to:
myImage.transform = CGAffineTransformScale(myImage.transform, 1.03, 1.03);
This will modify the existing transform instead of making a new one.
精彩评论