Iphone 即使removedOnCompletion=FALSE,CABasicAnimation也会向后跳;和fillMode=kCAFillModeForwards;

Iphone 即使removedOnCompletion=FALSE,CABasicAnimation也会向后跳;和fillMode=kCAFillModeForwards;,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我想在我的图标上旋转一圈,这样它就会显示出前一个月的趋势 如果我在一个月前去,图标会跳回正常状态,并向上或向下移动 但是我想要一个平滑的动画 我试图构建多个CABasicAnimation实例,它成功了,但这并不好 以下是我的方法: -(void)rotateTrafficAnimation:(UIImageView *)imageView :(float)rotation { CABasicAnimation* rotationAnimation; rotationAnimat

我想在我的图标上旋转一圈,这样它就会显示出前一个月的趋势

如果我在一个月前去,图标会跳回正常状态,并向上或向下移动

但是我想要一个平滑的动画

我试图构建多个CABasicAnimation实例,它成功了,但这并不好

以下是我的方法:

-(void)rotateTrafficAnimation:(UIImageView *)imageView :(float)rotation {
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: rotation]; // M_PI/2.0
    //NSLog(@"PIHALBE: %f", M_PI/2.0);
    rotationAnimation.duration = 1;
    rotationAnimation.cumulative = YES;
    rotationAnimation.removedOnCompletion = FALSE;
    rotationAnimation.autoreverses = NO;
    rotationAnimation.fillMode = kCAFillModeForwards;
    rotationAnimation.repeatCount = 0; 
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

    [imageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];


    //[rotationAnimation autorelease];
}

那么,我如何才能在忽略了许多CABasicAnimation实例的情况下做到这一点呢?

因此,Maverick1st在评论中告诉我的内容对我来说很有用,所以非常感谢

rotation.fromValue

你有没有试过将:rotation.fromValue设置为动画presentationlayer的当前旋转值?这是个好主意,我会尝试一下。你能告诉我它是否有效吗?然后我会把它作为答案贴出来,这样你就可以接受了。:)