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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:16:25+00:00 2026-05-16T18:16:25+00:00

I have a CALayer object. In viewDidLoad: I set a transform to it using

  • 0

I have a CALayer object. In viewDidLoad: I set a transform to it using layer.transform = CATransform3DRotate(CATransform3DIdentity, M_PI/8.0, 0, 0, 1); This works.

After loading, I apply a CAKeyframeAnimation to animate the rotation of that layer. It also works and animation finishes correctly. To prevent the layer from removing the animation after completion I use

animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;

All of this works fine. But a problem occurs when I try to change the transform again (without animation) layer.transform = CATransform3DRotate(CATransform3DIdentity, M_PI/8.0, 0, 0, 1);. Nothing happens. Layer doesn’t change its transform to what I have specified. If I run the animation again, the animation will happen. But cannot change the transform property without animation.

Any help is appreciated..

  • 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-16T18:16:25+00:00Added an answer on May 16, 2026 at 6:16 pm

    OK, I managed to get this working.
    What I did was setting the layer.tranform just after calling [layer addAnimation:]. In that way, after the animation is finished, the layer will stay in the desired position as it is. Here is my code:

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    animation.repeatCount = 1;
    animation.duration = 3.0;
    animation.fromValue = [NSNumber numberWithDouble:currentRotationAngle];
    animation.toValue = [NSNumber numberWithDouble:newRotationAngle];
    
    [layer addAnimation:animation forKey:@"rotationAnimation"];
    [layer setAffineTransform:CGAffineTransformMakeRotation(newRotationAngle)];
    

    The problem I had was using layer.removedOnCompletion and layer.fillemode. I don’t have to use them. In the new way the layer will display the layer using the layer.transform after animation is complete. CAAnimations only update the layer’s presentationLayer (which maintains the layer’s visual state) while animating. When the animation is finished, it will revert the layer’s visual state to the one imposed by layer.transform.

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

Sidebar

Related Questions

I have a UIView object that rotates using CALayer 's transform: // Create uiview
I have one like this: CALayer *layer = stripeButton.layer; CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@bounds.origin.y];
I have a UITableViewCell subclass with backgroundView set to my own UIView object. This
I have a UIView class that I am using to have a CALayer. This
This is strange: I have a view containing a rotated CALayer. The layer is
I have a UIView that contains a number of CALayer subclasses. I am using
have written this little class, which generates a UUID every time an object of
I am using CATiledLayer as backing layer for my UIView, which I have put
Is that possible to have a CALayer over another one composed using a blending
I have two CALayer subclasses, each with their own drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx delegate. They

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.