views:

49

answers:

0

I am Using the Following animation for Wiggle effect once the animation is complete if i again fire the animation the image gives a jerk effect as per me its not starting from its current position Like in UIView animation we have setAnimationBeginsFromCurrentState like this property in CAKeyframeAnimation do we have anything similar to this and if i adjust the image after the end of animation it gives jerk effect after the animation is complete.

Any advice?

CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
anim.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:-0.05],
               [NSNumber numberWithFloat:0.05],
               nil];
anim.duration = 2.0f;
anim.autoreverses = YES;
anim.repeatCount = 6;
[TrainerImagetwo.layer addAnimation:anim forKey:@"wiggleRotation"];

anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
anim.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:-1],
               [NSNumber numberWithFloat:1],
               nil];
anim.duration = 2.0;
anim.autoreverses = YES;

anim.repeatCount = 4;
anim.additive = YES;
anim.fillMode=kCAFillModeForwards;
[TrainerImagetwo.layer addAnimation:anim forKey:@"wiggleTranslationY"];