【发布时间】:2012-08-17 11:42:06
【问题描述】:
我正在使用这段代码为 NSScrollView 滚动制作动画:
[NSAnimationContext beginGrouping];
NSClipView* clipView = [self contentView];
NSPoint newOrigin = [clipView bounds].origin;
newOrigin.x = page*kGalleryWidth;
[[clipView animator] setBoundsOrigin:newOrigin];
[NSAnimationContext endGrouping];
现在我正在尝试获取触发动画结束的事件。 我已经阅读了几行代码,使用 CAAnimation 可以轻松实现,但我做不到。
我已经尝试了以下代码:
CAAnimation *moveAnimation = [[self.contentView animationForKey:@"frameOrigin"] copy];
moveAnimation.delegate = self;
[self.contentView setAnimations:[NSDictionary dictionaryWithObject:moveAnimation forKey:@"frameOrigin"]];
-
(void)animationDidStop:(CAAnimation *)动画完成:(BOOL)flag{
NSLog(@"STOP!");
}
有人可以帮助我吗?
谢谢!
【问题讨论】:
标签: objective-c macos cocoa delegates caanimation