I'm using the following code to scale an image slightly larger and then back to its original size:
float width = image.image.size.width;
float newWidth = width * 1.05;
float height = image.image.size.height;
float newHeight = height * 1.05;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:.7f];
NSAnimationContext.currentContext.completionHandler = ^{
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:.7f];
[[image animator] setFrameSize:NSMakeSize(width, height)];
[NSAnimationContext endGrouping];
};
[[image animator] setFrameSize:NSMakeSize(newWidth, newHeight)];
[NSAnimationContext endGrouping];
The problem is that the image moves slightly up and to the right during the animation instead of staying in place.
How can I keep the image in place during the animation?
Thank you.