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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:20:02+00:00 2026-05-15T11:20:02+00:00

I have a problem I don’t understand regarding UIViews and Core Animation. Here’s what

  • 0

I have a problem I don’t understand regarding UIViews and Core Animation. Here’s what I want to do:

  • A small view is presented above a bigger view by putting it as one of its subviews.
  • When I click a button inside this view, the view should minimize and move to a specified CGRect.
  • Then the view is removed from its superview.

The first time I present, minimize-and-move and remove the view, everything works fine. But when I present the view again, it displays at the modified position (even though it’s supposed to be set at the original position by a call to theView.frame = CGRectMake(600.0, 160.0, 339.0, 327.0);), while all the different responder elements (buttons, textviews, etc.) contained in the view act as if they were at the original position. It’s like the view and the layer gets dissynchronized by the animation, and I do not know how to get them back in sync.

Having something like self.view.layer.frame = CGRectMake(600.0, 160.0, 339.0, 327.0); does not get anything right.

My minimize-and-move animation code is given below:

    [CATransaction flush];
    CABasicAnimation *scale, *translateX, *translateY; 
    CAAnimationGroup *group = [CAAnimationGroup animation]; 
    group.delegate = delegate; 
    group.duration = duration; 

    scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 
    translateX = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; 
    translateY = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; 

    scale.toValue = [NSNumber numberWithFloat:0.13];
    translateX.toValue = [NSNumber numberWithFloat:137.0];
    translateY.toValue = [NSNumber numberWithFloat:-290.0];

    group.animations = [NSArray arrayWithObjects: scale, translateX, translateY, nil];
    group.fillMode = kCAFillModeForwards; 
    group.removedOnCompletion = NO;

    [theView.layer addAnimation:group forKey:@"MyAnimation"];

How to get the layer back to the view after the animation?

  • 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-15T11:20:03+00:00Added an answer on May 15, 2026 at 11:20 am

    What happens if you remove these two lines?

    group.fillMode = kCAFillModeForwards; 
    group.removedOnCompletion = NO;
    

    What you are telling core animation with those lines is that you want it to continue to display in the forward (final) state of the animation. Meanwhile, you didn’t actually set the transform on the layer to have the properties you used for the animation. This would make things appear to be out of sync.

    Now, the issue you’re going to run into is that removing those lines will cause your transforms to revert back to the starting state when the animation has completed. What you need to do is actually set the transforms on the layer in order for them to hold their position when the animation completes.

    Another option is to leave the two lines in and then actually explicitly remove the animation from the layer instead of setting the layer frame as you mentioned when you are ready to revert back to the original state. You do this with:

    [theView.layer removeAnimationForKey:@"MyAnimation"];
    

    The -removedOnCompletion property told the layer not to remove the animation when it finished. Now you can explicitly remove it and it should revert back.

    HTH.

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

Sidebar

Related Questions

I have a problem I don't understand: Behind any View I have a controller
I still have a problem with the splash screen. I don't want to use
I have a problem I don't really understand. I have a class Node. template<class
I have a problem drawing something quickly in .NET. I don't think that any
One problem that I come across regularly and yet don't have a solution to
I have problem with return statment >.< I want to store all magazine names
I have a problem I don't know how to solve. I have an Indy10
I have a problem - I don't know the amount of data being sent
I have this problem and really don't know how to solve this. I'm having
I want to JOIN two table. Have no problem with that. I have problem

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.