如何永久地将CALayer旋转到最终位置?

我试图将CALayer旋转到特定角度,但是一旦完成动画,图层就会跳回原来的位置。如何正确旋转图层以使其保持在最终目的地? 这是我正在使用的代码
CABasicAnimation *rotationAnimation =[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //Rotate about z-axis
[rotationAnimation setFromValue:[NSNumber numberWithFloat:fromDegree]];
[rotationAnimation setToValue:[NSNumber numberWithFloat:toDegree]];
[rotationAnimation setDuration:0.2];
[rotationAnimation setRemovedOnCompletion:YES];
[rotationAnimation setFillMode:kCAFillModeForwards];
有什么建议?谢谢。     
已邀请:
好的我通过将removeOnCompletion设置为NO来修复它。
[rotationAnimation setRemovedOnCompletion:NO];
    
您正在添加动画,但您没有修改实际的基础属性。创建动画后,只需将图层的
transform
属性设置为包含相同的最终结果。     

要回复问题请先登录注册