Grouping two Core Animations with CAAnimationGroup causes one CABasicAnimation to not run

后端 未结 2 1415
迷失自我
迷失自我 2020-12-28 10:19

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 *         


        
2条回答
  •  甜味超标
    2020-12-28 10:56

    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.

提交回复
热议问题