代码如下:
CABasicAnimation *rotateWhenBoom = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotateWhenBoom.fromValue = @0;
rotateWhenBoom.toValue = @(M_PI*2.0);
rotateWhenBoom.duration = 0.3f;
rotateWhenBoom.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
CAAnimationGroup *boom = [CAAnimationGroup animation];
boom.animations = @[[self moveOutWithBtn:btn], rotateWhenBoom];
boom.fillMode = kCAFillModeForwards;
boom.removedOnCompletion = NO;
效果: effect
在动画之前,视图都是水平的。我为这些视图添加了旋转动画,旋转的toValue为2 * PI。为什么在动画之后它们不是水平的? 在此先感谢!!
答案 0 :(得分:0)
你的最后两行代码:
boom.fillMode = kCAFillModeForwards;
boom.removedOnCompletion = NO;
表示图层保持最终动画状态,并且动画在完成时不会自动从图层中删除。您可能想要删除最后一行boom.removeOnCompletion = NO
CALayer和CAAnimation的一个很好的指南解释了这一点:https://www.objc.io/issues/12-animations/animations-explained/