I want to set animation for NSButton in my mac application.
I followed the below link for the same, but below code is working for iOS, not for Mac.
How to rotate a flat object around its center in perspective view?
What I want to achieve:
Basically, I want to rotate an image clockwise from the center point of the image just like the above code works for iOS.
Issue currently having:
In Mac app, the image is rotating from its corner point, not from the center.
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.duration = 1.0;
animation.repeatCount = INFINITY;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[btnScan setWantsLayer:YES];
[btnScan.layer addAnimation:animation forKey:@"transform.rotation.z"];