I'm trying to rotate the contents of an NSView
(NSButton
) in-place (I.e. from the center. I want to convert -
into |
). This can be done with setFrameCenterRotation:
… However, I'm trying to animate this, and
[[myview animator] setFrameCenterRotation: 90];
causes the control to first jump to the right, and then rotate around the bottom-left corner (0,0) back to the original location.
Some people have suggested first setting the anchorPoint
:
[[myview layer] setAnchorPoint: NSMakePoint(0.5, 0.5)];
but for some reason the animation cancels this out and it gets reset to (0, 0).
So, has anybody figured out how to animate an in-place rotation of an NSView
?
This doesn't happen if you add the control from interface builder and rotate it using its IBOutlet. You will not have to use "setAnchorPoint:" method; "setFrameCenterRotation:" method itself will work. However the same thing happened to me when I tried to rotate a NSButton I have in my NSCell as a subview. The solution was to have an NSView as a subview in the controlView (refer the NSCell subclass below) and NSButton I require rotation as a subview of that new NSView.