Re: Looping CAKeyframeAnimation stop in place?
Re: Looping CAKeyframeAnimation stop in place?
- Subject: Re: Looping CAKeyframeAnimation stop in place?
- From: David Duncan <email@hidden>
- Date: Fri, 09 Nov 2012 13:30:20 -0800
This is probably the simplest way to do it: http://developer.apple.com/library/mac/#qa/qa1673/_index.html
On Nov 9, 2012, at 11:53 AM, Eric E. Dolecki <email@hidden> wrote:
> I have a UIImageView that I spin forever (think a top-down view of a spool
> in a tape cassette). However I would like to stop the rotation animation &
> when it does NOT reset the UIImageView to it's original starting position.
>
> I have this to start it:
>
> CAKeyframeAnimation *rotationAnimation;
>
> rotationAnimation = [CAKeyframeAnimation animationWithKeyPath:@
> "transform.rotation.z"];
>
>
>
> rotationAnimation.values = [NSArray arrayWithObjects:
>
> [NSNumber numberWithFloat:0.0 * M_PI],
>
> [NSNumber numberWithFloat:0.75 * M_PI],
>
> [NSNumber numberWithFloat:1.5 * M_PI],
>
> [NSNumber numberWithFloat:2.0 * M_PI], nil];
>
> rotationAnimation.calculationMode = kCAAnimationPaced;
>
>
>
> rotationAnimation.removedOnCompletion = NO;
>
> rotationAnimation.fillMode = kCAFillModeForwards;
>
> rotationAnimation.timingFunction = [CAMediaTimingFunction
> functionWithName:kCAMediaTimingFunctionLinear];
>
> rotationAnimation.duration = 5.0;
>
> rotationAnimation.repeatCount = INFINITY;
>
> CALayer *layer = [leftSpool layer];
>
>
>
> [layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
>
> And this to stop it:
>
> //This is resetting the rotation to 0 - a visible jump
>
> [leftSpool.layer removeAnimationForKey:@"rotationAnimation"];
>
>
> I am looking for a way to start it, stop at current angle, and then restart
> at current angle...
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden