这是我的代码片断为可可应用程序使用核心动画,不知何故动画不显示。动画不显示
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDelegate:self];
NSRect pos = [imageView frame];
[animation setFromValue:[NSValue valueWithRect:pos]];
NSPoint point = NSMakePoint(pos.origin.x-40, pos.origin.y);
[animation setToValue:[NSValue valueWithPoint:point]];
[animation setDuration:2.0];
[[imageView animator] addAnimation:animation forKey:@"myTest"];
,而这是工作代码:
NSRect position = [imageView frame];
position.origin.x -= 40;
[[imageView animator] setFrame:position];
但自动翻转不起作用。
第一个有问题吗?以及如何使第二个反向运动工作?谢谢!