• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Does CAAnimationGroup groups animations for a single layer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does CAAnimationGroup groups animations for a single layer?


  • Subject: Re: Does CAAnimationGroup groups animations for a single layer?
  • From: Gustavo Pizano <email@hidden>
  • Date: Tue, 23 Feb 2010 19:15:15 +0100

Duncan Hi.
I see... mm.
Ok.. then I will change it to CABasicAnimation, and I will handle the multiple call back.

>  Additionally, rather than changing the anchorPoint do your animation based on the center of the view instead of it's frame's origin (which will also continue to work as you expect should you need to do an animation on a layer that has a transform).

So When creating the CABasicAnimation I shall place the fromValue and ToValue to be the translated values? or I should set the CATransform3d with the translated layer position?

thanks for your help

Gustavo

On Feb 23, 2010, at 6:36 PM, David Duncan wrote:

> On Feb 23, 2010, at 6:45 AM, Gustavo Pizano wrote:
>
>> //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"];
>
> As an FYI, using a CAKeyframeAnimation to move a layer from point A to point B is a bit of overkill. You can use a CABasicAnimation to do the same thing by using the to/from values. If you plan to make the transit path more complex, then a keyframe animation is perfectly fine however. If you aren't tied to using Core Animation directly however, you can do this even more simply using UIView's +beginAnimations:context: and +commitAnimations methods.
>
> Additionally, rather than changing the anchorPoint do your animation based on the center of the view instead of it's frame's origin (which will also continue to work as you expect should you need to do an animation on a layer that has a transform).
>
>> 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?
>
>
> Core Animation always copies an animation when you add it to a layer. Layers cannot share animations, and you cannot group animations across layers.
>
> You will have to deal with getting called back multiple times (once per animation).
> --
> David Duncan
> Apple DTS Animation and Printing
>

_______________________________________________

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

  • Follow-Ups:
    • Re: Does CAAnimationGroup groups animations for a single layer?
      • From: David Duncan <email@hidden>
References: 
 >Does CAAnimationGroup groups animations for a single layer? (From: Gustavo Pizano <email@hidden>)
 >Re: Does CAAnimationGroup groups animations for a single layer? (From: David Duncan <email@hidden>)

  • Prev by Date: Re: High Level Toolkit -- is it obsolete or not?
  • Next by Date: Re: -commitEditing NSAlert not always presented as a sheet
  • Previous by thread: Re: Does CAAnimationGroup groups animations for a single layer?
  • Next by thread: Re: Does CAAnimationGroup groups animations for a single layer?
  • Index(es):
    • Date
    • Thread