Search code examples
macoscocoacore-animation

Core Animation on Layer-Backed View with rotation


Just want to rotate NSView (without animation). Layer backed-view (setWantsLayer=YES). Works with opacity, position. But when I try rotate with

[view.layer setValue:[NSNumber numberWithInt:45*M_PI/180] forKeyPath:@"transform.rotation.y"];

Nothings happened.


Solution

  • You are rotating 0 degrees.

    45 * π / 180 = 0.785 which as an int is 0.

    Change your NSNumber to a float or double

    [NSNumber numberWithFloat:45*M_PI/180]