UIView的动画整圈旋转与UIViewAnimationOptionCurveEaseInOut逆转 [英] UIView animation full circle rotation reverse with UIViewAnimationOptionCurveEaseInOut
本文介绍了UIView的动画整圈旋转与UIViewAnimationOptionCurveEaseInOut逆转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[UIView animateWithDuration:3 delay:0 options:( UIViewAnimationOptionCurveEaseInOut |
UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat |
UIViewAnimationOptionAllowUserInteraction) animations:^{
self.animatedImageView.transform = CGAffineTransformRotate(self.animatedImageView.transform, M_PI);
} completion:^(BOOL finished){}];
这动画怎么可能一整圈旋转,同时还加速和deaccelerating。如果我使用2 * M_PI动画是不动的。
How can this animation be a full circle rotation while still accelerating and deaccelerating. if I use 2 * M_PI the animation is not moving.
推荐答案
我认为这应该为你工作:
I think this should work for you:
- (IBAction)rotate:(UIButton *)sender {
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = @(M_PI * 2.0);
rotationAnimation.duration = 1;
rotationAnimation.autoreverses = YES;
rotationAnimation.repeatCount = HUGE_VALF;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.iv.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
这篇关于UIView的动画整圈旋转与UIViewAnimationOptionCurveEaseInOut逆转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文