I'm having a bit of trouble with getting CoreAnimation to rotate an NSView about its center point. All I want to do is rotate an NSView while keeping its center point static so that the object appears to rotate in place.
The way I chose to do this involves the use of the animator
property in NSView. The code is as follows:
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:1.0];
[[view animator] setFrameCenterRotation:45.0];
[NSAnimationContext endGrouping];
Where view
is the NSView that I am trying to rotate. The result of this code makes the object abruptly shift to the right somewhat then does the rotation. The final result is correct, but the animation doesn't look right because of the movement it makes in the beginning. I'm assuming that this is because the way that setFrameCenterRotation:
works is that it shifts the frame origin to the view's center point first, then makes the rotation.
What am I doing wrong here? Is there a better way, perhaps, to rotate an NSView about the center? Thanks a lot!