我有一个iPhone的基本旋转动画。有什么办法可以“暂停”动画,以保持视图的位置?我想这样做的一种方式是导致动画“完成”而不是调用“删除”它,我将如何做到这一点?有没有办法暂停CABasicAnimation?
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2];
rotationAnimation.duration = 100;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.fillMode = kCAFillModeForwards;
[myView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
这对我来说工作得很好,但是当我处于暂停状态,并且旋转我的设备时,我失去了与应用程序交互的所有能力。它实际上并没有坠毁,但它看起来“冻结”。是否与“willAnimateRotationToInterfaceOrientation”有冲突? – YoCoh
@YoCoh,它确实可以暂停视图的标准旋转动画,并且在动画过程中,用户交互可能被禁用(可能是这种情况),标准动画并没有完成,最终导致UI停留在禁用状态。不知道如何解决方法 – Vladimir
http://ronnqvi.st/controlling-animation-timing/解释此代码的工作原理 –