Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6650215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:51:59+00:00 2026-05-26T00:51:59+00:00

I am trying to learn core-animation for the iOS/iPhone. My root layer contains a

  • 0

I am trying to learn core-animation for the iOS/iPhone. My root layer contains a lot of sublayers (sprites) and thay should spin when they are removed…

My plan was to add a spinning animation and then remove the sprite when the animationDidStop is invoked. The problem is that the sprite layer is not a parameter to animationDidStop!

What is the best way to find the specific sprite layer from animationDidStop?
Is there a better way to make the sprite spin when it is removed? (ideally I would like to use kCAOnOrderOut but I could not make it work)

-(void) eraseSprite:(CALayer*)spriteLayer {
    CABasicAnimation* animSpin = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    animSpin.toValue = [NSNumber numberWithFloat:2*M_PI];
    animSpin.duration = 1; 
    animSpin.delegate = self;
    [spriteLayer addAnimation:animSpin forKey:@"eraseAnimation"];    
}



- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag{
    // TODO check if it is an eraseAnimation
    //      and find the spriteLayer

    CALayer* spriteLayer = ??????   
    [spriteLayer removeFromSuperlayer]; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:52:00+00:00Added an answer on May 26, 2026 at 12:52 am

    Found this answer here cocoabuilder but basically you add a key value to the CABasicAnimation for CALayer that’s being animated.

    - (CABasicAnimation *)animationForLayer:(CALayer *)layer
    {
         CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
         /* animation properties */
         [animation setValue:layer forKey:@"animationLayer"];
         [animation setDelegate:self];
         return animation;
    }
    

    Then reference it in the animationDidStop callback

    - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
     {
         CALayer *layer = [anim valueForKey:@"animationLayer"];
         if (layer) {
             NSLog(@"removed %@ (%@) from superview", layer, [layer name]);
             [layer removeFromSuperlayer];
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn about core data on the iPhone, and I am
I am learning to develop iPhone applications using iOS 5. I am trying to
I've been trying to learn Core Data, and browsing through questions on Stack Overflow
I just noticed while trying to learn to read GHC Core, that the automatically
I am a newbie in iOS application development, but I am trying to learn
Trying to learn a bit of CSS and I want a horizontal navbar and
Trying to learn a bit about PDO and is going through this tutorial .
Trying to learn about php's arrays today. I have a set of arrays like
Trying to learn MVP pattern with C#... Does anyone know of any particularly good
In trying to learn how to create objects in ActionScript, I have had no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.