• 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: Removing CALayer after Animation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing CALayer after Animation


  • Subject: Re: Removing CALayer after Animation
  • From: Matt Long <email@hidden>
  • Date: Tue, 6 Jan 2009 13:45:18 -0700

Bridger,

As far as I can tell there is nothing inherent in the CA API to do what you want, however, KVC is available to you. When you create your animation, do this:

[animation setValue:objectLayer forKey:@"parentLayer"];

Where objectLayer is the layer the animation is going to be run on. Then, in your -animationDidStop, you can grab the layer like this:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
  CALayer *layer = [theAnimation valueForKey:@"parentLayer"];
  if( layer )
  {
    NSLog(@"The layer object was: %@ (%@)", layer, [layer name]);
    [layer removeFromSuperlayer];
  }
}

I named my layer when I created it with a call to [objectLayer setName:@"parentLayer"] in this code, so the NSLog in - animationDidStop won't display the name unless you've done the same.

Best regards,

-Matt


On Jan 3, 2009, at 9:47 PM, Bridger Maxwell wrote:

Another question on Core Animation.

I am creating temporary CALayers, and animating them across a parent layer.
I would like to delete the layers once they have reached their destination.
I are using the delegate method animationDidStop:finished: on the animation,
but it returns only a reference to the animation object that finished, and I
don't know how to figure out what layer the animation was associated.
Without this information, I don't know which layer we should remove. Any
help would be great.


Thank You,
Bridger Maxwell
_______________________________________________

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: Removing CALayer after Animation
      • From: "Bridger Maxwell" <email@hidden>
References: 
 >Removing CALayer after Animation (From: "Bridger Maxwell" <email@hidden>)

  • Prev by Date: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • Next by Date: Re: QTMovieLayer and QCCompositionLayer Don't Start
  • Previous by thread: Removing CALayer after Animation
  • Next by thread: Re: Removing CALayer after Animation
  • Index(es):
    • Date
    • Thread