I have a very simple problem and I am pulling my hair out. I am trying to revitalize the NSButton movement. Now I know about almost simplicity:
[[button animator] setFrame:newCGRect];
However, I would like to increase the time it takes a button to move. So, I looked at a slightly more complex CABasicAnimation. I think I'm doing everything right, but NSButton is not moving at all.
CGPoint center = CGPointMake(10, 20);
CALayer *layer = button.layer;
layer.position = CGPointMake(button.frame.size.width / 2, button.frame.size.height / 2);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [layer valueForKey:@"position"];
[animation setToValue:[NSValue valueWithPoint:center]];
[animation setFillMode:kCAFillModeForwards];
[animation setRemovedOnCompletion:NO];
[animation setDuration:3.0];
[layer addAnimation:animation forKey:@"position"];
Here's the NSButton button. I set the position of the layer to the center of the button because I think the “position” should refer to the center. Then all I do is move the (presumably) button to the center, in the animation, for 3 seconds. I add animation to the layer and then nothing happens.
, - , ? , , - ?