MZimmerman6
MZimmerman6

Reputation: 8613

OS X 10.7 Animation Did stop selector

I am trying to figure out how to set a call back for when my nsview animator stops. Anyone know how to do this.

NSRect frame = blob.frame;
frame.origin.x = animationStopX;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:timeToDisappear];
[[blob animator] setFrame:frame];
[NSAnimationContext endGrouping];

Upvotes: 1

Views: 506

Answers (2)

Yoav
Yoav

Reputation: 6098

On 10.8, NSAnimationContext has completionHandler property which you can use with a block.

Upvotes: 2

Dima Portenko
Dima Portenko

Reputation: 3854

You can set delegate for frameOrigin animation.

CAAnimation *moveAnimation = [[blob animationForKey:@"frameOrigin"] copy];
moveAnimation.delegate = self;
[blob setAnimations:[NSDictionary dictionaryWithObject:moveAnimation forKey:@"frameOrigin"]];
[moveAnimation release];

And override end animation delegate method

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag

Upvotes: 0

Related Questions