Hello all.

I have 5 UIButtons., now Im attempting to make a "fly-in" when the application 
launch, Im positioning the buttons outside the view's frame, and creating a 
CGPathRef for each button's path I want them to follow.
So for instance,  for one button Im doing the following:

//movRect exists already

//Path for Movies
        moviesPath = CGPathCreateMutable();
        CGPathMoveToPoint(moviesPath, NULL, movRect.origin.x, movRect.origin.y);
        CGPathAddLineToPoint(moviesPath, NULL, 32.0,81.0);
        CGPathRef moviPathRef = CGPathCreateCopy(moviesPath);
CGPathRelease(moviesPath);

//Create the layers of the buttons _moviesButton is one of the UIButtons
        CALayer * moviesLayer = _moviesButton.layer;
        moviesLayer.anchorPoint = CGPointMake(0.0f, 0.0f);
        CAKeyframeAnimation * animatedButonsAnimation = [CAKeyframeAnimation 
animationWithKeyPath:@"position"];
        animatedButonsAnimation.duration = 0.4;
        animatedButonsAnimation.delegate = self;
        animatedButonsAnimation.path = moviPathRef;
        animatedButonsAnimation.timingFunction=[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        [moviesLayer addAnimation:animatedButonsAnimation 
forKey:@"animateButton"];

        //Release the copies
        CGPathRelease(moviPathRef);

and in my delegate method:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
        NSLog(@"Animations stoped");
        //[animatedIconView setHidden:YES];
        CGRect movRect = _moviesButton.frame;
        movRect.origin.x = 32.0f;
        movRect.origin.y = 81.0f;
        _moviesButton.frame = movRect;
        ..
        ..
}

So, right now all works as expected, but the delegate method its being called 5 
times, once per animation,  which in fact Im reusing the one I created for the 
movies Layer just with a different path and add it to a different button layer.
I wanted then somehow to use CAAnimationGropu to store each CAKeyAnimation in 
the array argument, and somehow just start the group animation, and my delegate 
method will be called just once... is my theory right?

In that case, I can't not call the [<CALayer> 
addAnimation:animatedButonsAnimation forKey:@"animateButton"]; otherwise the 
animation will fire, so to what layer should I add the CAAnimationGroup? or 
what shall I do?

Thanks in advance.


Gustavo_______________________________________________

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