views:

29

answers:

1

Hi all,

I have the following core animation code in my app :

-(void)startCoreAnimation

    [UIView beginAnimations:@"IconFade" context:Icon];
   [UIView setAnimationCurve:UIViewAnimationCurveLinear];
   [UIView setAnimationDuration:1];

   [UIView setAnimationRepeatAutoreverses:YES];
   [UIView setAnimationDelegate:self];
   [UIView         setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];

   icon.alpha=0.0;
   [UIView commitAnimations];
   break;

And then when the animation finishes :

-(void)animationFinished : (NSString *)theAnimation finished : (BOOL)flag context : (void *)context {


 ((UIView *)context).alpha = 1.0;
 ((UIView *)context).transform = CGAffineTransformIdentity;

 [self startCoreAnimation];

}

The problem is that after the animation finished the icon "jumps" back to it's alpha state of 1. It looks like the icon fades, unfades then goes to alpha 0 and then back to alpha 1. Between the last two steps (alpha 0 to alpha1) there is a small gap which is causing the stutter. Can anyone help ?

Thanks,

Martin

A: 

If you just want to loop the animation, you could also use

[UIView setAnimationRepeatCount:1e100f];

According the documentation:

Setting the repeatCount to 1e100f will cause the animation to repeat until it is removed from the layer.

Jeroen de Leeuw