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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:54:54+00:00 2026-06-17T12:54:54+00:00

I have 3 animations running in a group: position, scale and rotation However my

  • 0

I have 3 animations running in a group: position, scale and rotation

However my rotation animation does not happen smoothly. It happens abruptly in the beginning, while other animations happen smoothly.

Here is my code:

//CABasicAnimation *scaleAnimation
//CABasicAnimation *moveAnimation
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
rotationAnimation.autoreverses = NO;  

rotationAnimation.toValue = [NSNumber numberWithFloat: 0];//-(M_PI/3)];
//below line shows the end state, if removed, the layer will assume its initial position after animation, something which I don't want.
[layer setTransform:CATransform3DMakeRotation(0, 0, 1, 0)];    

CAAnimationGroup *theGroup = [CAAnimationGroup animation];
//Code for adding all 3 animations to the group

Edit:

rotationAnimation.toValue = [NSNumber numberWithFloat: -(M_PI/3)];

Removed final transform value from the place of animation declaration, and added it to delegate. (note that in case of animation group, individual animation delegates do not get hit, only the group delegate worked).

Under delegate:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{   
    NSString * animName = [theAnimation valueForKey:@"animationName"];
    CALayer* layer = [theAnimation valueForKey:@"animationLayer"];

    if ([animName isEqualToString:@"MoveZoomOut"])
    {

       if ([layer.name isEqualToString:@"Layer1"])
          [layer setTransform:CATransform3DMakeRotation(-M_PI/3, 0, 1, 0)];
       else if ([layer.name isEqualToString:@"Layer2"])
          [layer setTransform:CATransform3DMakeRotation(M_PI/3, 0, 1, 0)];
       else
          [layer setTransform:CATransform3DMakeRotation(0, 0, 1, 0)];
    }

    if ([layer respondsToSelector:@selector(setContentsScale:)])
    {
        layer.contentsScale = [UIScreen mainScreen].scale;
    }
}
  • 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-17T12:54:56+00:00Added an answer on June 17, 2026 at 12:54 pm

    I have 3 animations running in a group: position, scale and rotation

    I suspect that since you are animating both scale and rotation, which is done through the transform property, there might be a clash.

    Try to animate scale and rotation in a single animation by concatenating the 2 transforms into one:

    CATransform3D t = CATransform3DMakeRotation(0, 0, 1, 0)];
    [layer setTransform:CATransform3DScale(t, sx, sy, sz)]; 
    

    EDIT:

    I understand that what is happening is pretty unusual, so I will give you a couple of hints as to tricks that in several occasions helped me. I understand, you have 3 layers to animate.

    1. wrap each layer animations in [CATransaction begin]/[CATransaction commit];

    if that does not help,

    1. do not set the final value of the property you are going to animate right after creating the animation itself; rather set it in the animation delegate animationDidStop:finished: method.

    In other words, given your code:

    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    rotationAnimation.autoreverses = NO;  
    
    rotationAnimation.toValue = [NSNumber numberWithFloat: 0];//-(M_PI/3)];
    //below line shows the end state, if removed, the layer will assume its initial position after animation, something which I don't want.
    [layer setTransform:CATransform3DMakeRotation(0, 0, 1, 0)];    
    
    CAAnimationGroup *theGroup = [CAAnimationGroup animation];
    

    don’t do [layer setTransform:CATransform3DMakeRotation(0, 0, 1, 0)]; there. Rather, do it in:

    - (void)animationDidStop:(CAAnimation*)anim finished:(BOOL)flag {
       [layer setTransform:CATransform3DMakeRotation(0, 0, 1, 0)];
    }
    

    Since you will have more than one animation going on (and presumably use the same delegate for all of them), you will need a way to tell which animation the animationDidStop: method refers to. To this aim, you could do, e.g.:

    //-- se the delegate
    rotationAnimation.delegate = self;
    [rotationAnimation setValue:layer forKey:@"animationLayer"];
    

    and in the delegate method:

    - (void)animationDidStop:(CAAnimation*)anim finished:(BOOL)flag {
    
       [CATransaction begin];
       [CATransaction setDisableActions:YES];
    
       CALayer* layer = [anim valueForKey:@"animationLayer"];
       layer.transform = ...;
    
       [CATransaction commit];
    
    }
    

    I know that this seems a bit contrived. And it is. But it is the only way I could fix an issue similar to what you are reporting.

    Hope this helps.

    EDIT:

    For the glitch when using animationDidStop:, try to wrap animationDidStop: content in:

    [CATransaction begin];
    [CATransaction setDisableActions:YES];
    ...
    [CATransaction commit];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several jquery animations running, each of which will need to be somewhat
I have an animation running in the background, and I want to register a
I have an AnimationSet that does 3 different animations. After the animations end, I
I have a web page with animations ( JQuery Animation ) all over the
I have the following animations in my web page: $(.anim-item).not(this).animate({ opacity: 0, }, {
So I currently have an application that is fairly complex with large-scale animations and
I have multiple UIView animations running in my app. They are very short, and
as topic describes, calling popToRootViewControllerAnimated / popToViewControllerAnimated does not do any animation anymore. the
I have an issue where my animations work perfectly, however when the .hide(); is
I have the following code with CSS Animations running on the .in and .out

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.