Dear list,

I have a CALayer called textLayer which displays some message, for example 
"Hello". I perform two consecutive animations on it. At the end of the first 
animation, the text is no more visible. The message then gets updated (to "Good 
bye", let's say) and the second animation brings the layer back to its initial 
position.

My problem is that at the end of the first animation, the "Hello" message shows 
up in its initial position for a fraction of a second.
I've tried to set the fillMode of the first animation to kCAFillModeForwards 
with no effect.

Here is the code for the setup of the animations and the animationDidStop: 
delegate call for the first one :

textRotationFirstHalf = [[CABasicAnimation animation] retain];
textRotationFirstHalf.fromValue = [NSNumber numberWithFloat: 0.0];
textRotationFirstHalf.toValue = [NSNumber numberWithFloat: M_PI / 2];
textRotationFirstHalf.keyPath = [NSString stringWithString: 
@"transform.rotation.x"];
textRotationFirstHalf.timingFunction = [CAMediaTimingFunction functionWithName: 
kCAMediaTimingFunctionEaseIn];
textRotationFirstHalf.delegate = self;
[textRotationFirstHalf setValue:@"Rotation Continues" forKey:@"What Next"];
textRotationFirstHalf.duration = 0.25;
        
textRotationSecondHalf = [[CABasicAnimation animation] retain];
textRotationSecondHalf.fromValue = [NSNumber numberWithFloat: M_PI / 2];
textRotationSecondHalf.toValue = [NSNumber numberWithFloat: 0];
textRotationSecondHalf.keyPath = [NSString stringWithString: 
@"transform.rotation.x"];
textRotationSecondHalf.timingFunction = [CAMediaTimingFunction 
functionWithName: kCAMediaTimingFunctionEaseOut];
textRotationSecondHalf.duration = 0.25;

-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
  NSString *value = [theAnimation valueForKey: @"What Next"];
  if([value isEqual:@"Rotation Continues"])
  {
    [self updateText];
    [textLayer addAnimation: textRotationSecondHalf forKey: @"End Rotation"];
  }
}

The updateText method just calls [textLayer setNeedsDisplay]  which results in 
the display of the "Good bye" message, because a state variable has changed 
meanwhile.

What can I do to recover the smoothness of this animation sequence and get rid 
of the unwanted frame ?

Thank you for any ideas,

Rodolfo Niborski
http://itunes.com/apps/yiddishforkids1-alefbeys_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to