2012-04-16 212 views
1

我正在旋转45度的箭头。动画结束时,箭头返回到原始状态(0度)。我需要箭头不会回到原始状态,它会在动画结束时旋转45度。旋转动画

CABasicAnimation *fullRotationShort = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
fullRotationShort.fromValue = [NSNumber numberWithFloat:0]; 
fullRotationShort.toValue = [NSNumber numberWithFloat:M_PI/28*4.7]; 
fullRotationShort.duration = 1.0f; 
fullRotationShort.repeatCount = 1; 
[imgViewArrowShort.layer addAnimation:fullRotationShort forKey:nil]; 

回答

1

设置属性:

fullRotationShort.fillMode = kCAFillModeForwards; 
fullRotationShort.cumulative = YES; 
    fullRotationShort.removedOnCompletion=NO; 
+0

这是行不通的。 – Sveta 2012-04-16 11:53:31

+0

哦,我忘记了一些行.....你再次检查.. ?? – userar 2012-04-16 11:55:24

+0

谢谢!有用! – Sveta 2012-04-16 11:57:37

6

假设你的箭是一个UIImageView命名arrow
你真的不需要这样复杂的CAAnimations。

[UIView animateWithDuration:1.0 animations:^{ 
    arrow.transform = CGAffineTransformMakeRotation(0.25 * M_PI); 
}]; 
+0

救了我的一天:)感谢这样的简单和优雅的解决方案。 – 2015-07-09 13:33:44