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

  • SEARCH
  • Home
  • 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 7855633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:26:39+00:00 2026-06-02T20:26:39+00:00

This is interesting… I’d think that by doing this CABasicAnimation* a = [CABasicAnimation animationWithKeyPath:@opacity];

  • 0

This is interesting… I’d think that by doing this

CABasicAnimation* a = [CABasicAnimation animationWithKeyPath:@"opacity"];
    a.fromValue = [NSNumber numberWithFloat:0.];
    a.toValue = [NSNumber numberWithFloat:1.];
    a.duration = .4;
    a.fillMode = kCAFillModeBoth;
    a.removedOnCompletion = NO;

CGFloat timeOffset = 0;
for(CALayer* layer in layers)
{
    a.beginTime = [someCommonSuperView.layer convertTime:CACurrentMediaTime()fromLayer:nil] + timeOffset;
    [layer addAnimation:a forKey:nil];
    timeOffset += .4;
}

I am actually always modifying the same CABasicAnimation’s beginTime and just incrementing its reference count. So thatI wouldn’t get a series of layers fading in one after the other but rather should be messing up the start time of all of them, possibly causing all of them to just show up at once at the time of the last one. But the above code actually seems to work in that the layers fade in sequentially.

So does it make sense to reuse the animation in this way? So as to not create a new instance of it on each pass?

Is addAnimation actually making a deep copy of the animation instead of increasing the reference count?

  • 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-06-02T20:26:41+00:00Added an answer on June 2, 2026 at 8:26 pm

    According to the docs:

    - (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key

    Add an animation object to the receiver’s render tree for the specified key.

    Parameter anim:

    The animation to be added to the render tree. Note that the object is
    copied by the render tree, not referenced. Any subsequent
    modifications to the object will not be propagated into the render
    tree.

    So I’d say it’s safe to reuse the same CAAnimation object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this interesting site, that helps me understand derivatives, http://www.numberempire.com/derivatives.php , It seems
There is this interesting game, that has numbers in a grid, where each number
I found this interesting tutorial that explains the concept of view bean with some
I just read this interesting question about a random number generator that never generates
I have this interesting situation. I have a bunch of structs that hold a
i have been reading this interesting article which is increasing my every growing confusion
there's this interesting problem i can not solve myself. I will be very glad,
I recently came in contact with this interesting problem. You are given a string
In Matters Computational I found this interesting linear search implementation (it's actually my Java
As part of my ecommerce application, I have this interesting problem, I've been trying

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.