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 6753225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:08:07+00:00 2026-05-26T13:08:07+00:00

Is there an issue with reading the presentation position while it’s paused? I’m trying

  • 0

Is there an issue with reading the presentation position while it’s paused?

I’m trying to pause and resume a CALayer. Once the CALayer is paused, I want to update the layer’s position with it’s current presentation position.
When I try do this, the layer flickers slightly once I resume the layer.

This is the code I’m using to pause and resume the CALayer (based on a Technical Q&A QA1673 supplied by Apple):

CFTimeInterval pausedTime;
void pauseLayer(CALayer *layer)
{
    pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
    layer.speed = 0.0;
    layer.timeOffset = pausedTime;
    layer.beginTime = 0;
//    layer.position = ((CALayer*)[layer presentationLayer]).position;
}
void resumeLayer(CALayer *layer)
{
    layer.speed = 1.0;
    layer.timeOffset = 0.0;
    layer.beginTime = 0.0;

    CFTimeInterval _elapsedTimeSincePaused = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
    layer.beginTime = _elapsedTimeSincePaused;
}

If I uncomment the layer.position = ((CALayer*)[layer presentationLayer]).position; in pauseLayer, the layer flickers once I call resumeLayer.

This is my animation code:

- (void) startAnimation:(id)sender
{
    layer10Animation = [CABasicAnimation animationWithKeyPath:@"position.x"];
    layer10Animation.duration = 1;
    layer10Animation.toValue = [NSNumber numberWithInt:300];
    layer10Animation.fromValue = [NSNumber numberWithInt:20];
    layer10Animation.repeatCount = 100;
    layer10Animation.autoreverses = YES;

    [layer10 addAnimation:layer10Animation forKey:nil];
}

Best regards

  • 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-26T13:08:08+00:00Added an answer on May 26, 2026 at 1:08 pm

    There’s not an issue with updating aCALayerposition whilst it’s paused. Naturally however it will give the flicker that you mention. That’s because you are updating the layer’s position mid animation.

    Don’t forget that creating aCABasicAnimationand adding it to aCALayerdoesn’t change the layer’s settings. It creates an animation using the layer, but it doesn’t change the layer.

    That’s why after the animation has finished, you’ll see the layer back in exactly the same position it was before.

    Because of this, if you are animating a layer from A to B, if you want the layer to appear at B after the animation has finished, you’ll need this delegate callback:

    - (void)animationDidStart:(CAAnimation *)theAnimation
    { 
        [CATransaction begin];
        [CATransaction setValue:(id)kCFBooleanTrue
                         forKey:kCATransactionDisableActions];
        myLayer.position = targetPosition;    
        [CATransaction commit];
    }
    

    Yep, it’sanimationDidStart. If we did it usinganimationDidStopthen you would see another flicker. The layer would be in the animation’s end position of B, then you’d see a flicker of it at A, and then you’d see it at B again.

    UsinganimationDidStartwe set the position to be thetargetPosition, i.e.B because that’s where we want to see it on completion.

    Now, regarding QA1673, what you are doing with this is setting the animation speed to zero, and getting a timestamp of the currentCACurrentMediaTime(). On resume, you put the speed back to normal, and apply any offsets incurred during the pause time.

    This all seems pretty confusing until you get the hang of it. Could I recommend some reading and videos?

    Definitely have a read of Core Animation Rendering Architecture.

    Videos that are highly recommended are:

    WWDC 2010 Sessions 424 and 425 Core Animation in Practice Parts 1 and 2

    WWDC 2011 Session 421 Core Animation Essentials

    and

    Developer Videos Session 716 Core Animation Techniques for iPhone and Mac

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

Sidebar

Related Questions

I am reading from a NetworkStream that is in a while loop. The issue
There is issue, when Uploadify plugin desn't POST more than 1 parameter. Tried 3
Is there an issue with IIS or ASP Classic where Request.ServerVariables(QUERY_STRING) returns blank if
This is a simplification of the issue (there are lots of ways of doing
The issue is there is a database with around 20k customer records and I
There is an issue that I cannot solve, I've been looking a lot in
I've got a duplicate content issue where there's two instances of my site indexed
There seems to be an issue simulating the backspace key with java.awt.Robot . This
There is a well known issue when it comes to using .NET value types
There are various posts on the web about this issue whereby the ComboBox only

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.