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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:10:27+00:00 2026-05-13T13:10:27+00:00

I have two animations that I’m trying to perform on a UILabel on the

  • 0

I have two animations that I’m trying to perform on a UILabel on the iPhone with OS 3.1.2. The first rocks the UILabel back and forth:

CAKeyframeAnimation *rock;
rock = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
[rock setBeginTime:0.0f];
[rock setDuration:5.0];
[rock setRepeatCount:10000];

NSMutableArray *values = [NSMutableArray array];
MovingMath *math = [[MovingMath alloc] init];

// Center start position
[values addObject:[math DegreesToNumber:0]];

// Turn right
[values addObject:[math DegreesToNumber:-10]];

// Turn left
[values addObject:[math DegreesToNumber:10]];

// Re-center
[values addObject:[math DegreesToNumber:0]];

// Set the values for the animation
[rock setValues:values];

[math release];

The second zooms the UILabel so that it becomes larger:

NSValue *value = nil;
CABasicAnimation *animation = nil;
CATransform3D transform;
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
transform = CATransform3DMakeScale(3.5f, 3.5f, 1.0f);
value = [NSValue valueWithCATransform3D:transform];
[animation setToValue:value];
transform = CATransform3DMakeScale(1.0f, 1.0f, 1.0f);
value = [NSValue valueWithCATransform3D:transform];
[animation setFromValue:value];
[animation setAutoreverses:YES];
[animation setDuration:30.0f];
[animation setRepeatCount:10000];
[animation setBeginTime:0.0f];

Adding either one of these animations directly to the UILabel’s layer works as expected.

However, if I try to group the animations together, the first “rocking” animation does not function:

CAAnimationGroup *theGroup = [CAAnimationGroup animation];

theGroup.duration = 5.0;
theGroup.repeatCount = 10000;
theGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
theGroup.animations = [NSArray arrayWithObjects:[self rockAnimation], [self zoomAnimation], nil]; // you can add more

// Add the animation group to the layer
[[self layer] addAnimation:theGroup forKey:@"zoomAndRotate"];

The order of adding the animations to the group does not matter. Instead of zooming, in the manner above, I tried changing the bounds, but that was unsuccessful as well. Any insight would be greatly appreciated. Thank you.

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

    You are attempting to simultaneously animate two changes to one property, your CALayer’s transform. In the first animation, you are using a helper keypath to change the transform to produce a rotation, and in the second you are changing the transform directly to produce a scaling. The second animation is overwriting the first, because you are constructing whole transforms that are only scaled and animating between them.

    It appears that you can cause both scaling and rotation of your layer to occur by using helper keypaths for both animations. If you change your code on the scaling animation to read

    CABasicAnimation *animation = nil;
    animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    [animation setToValue:[NSNumber numberWithDouble:3.5]];
    [animation setFromValue:[NSNumber numberWithDouble:1.0]];
    [animation setAutoreverses:YES];
    [animation setDuration:30.0f];
    [animation setRepeatCount:10000];
    [animation setBeginTime:0.0f];
    

    you should be able to have both rocking and scaling on your layer.

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

Sidebar

Related Questions

I have to perform two animations on an object simultaneously. For a number of
Possible Duplicate: jQuery delay between animations I have created two functions: One that animates
I'm trying to combine two animations programmatically. In that simplified example: Animation translate =
I'm using a ViewSwitcher that lets me easily flip back and forth between two
Hello I have problem to put together animations of two separate objects to second
I have two applications written in Java that communicate with each other using XML
I'm basically running two animations, one after the other, and it seems that they
I have two UIImageViews on my object, and I'm trying to animate them to
First, some visualization of the code. I have the following images that are dynamically
assume that i have two sequential methods, methodA and methodB ( methodB is called

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.