我正在使用下面的代码尝试让我的识别器在状态结束后继续旋转。无论我在CGAffineTransformRotate中设置多高值,它似乎只能获得一次旋转。
任何见解或建议都将受到赞赏。
感谢。
if([(UIRotationGestureRecognizer*)recognizer state] == UIGestureRecognizerStateEnded)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:6.55];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, 1000000000);
[UIView commitAnimations];
}
答案 0 :(得分:4)
您可能想尝试使用CABasicAnimation
- (void)rotate {
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:2.0] forKey:kCATransactionAnimationDuration];
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
animation.delegate = self;
[recognizer.layer addAnimation:animation forKey:@"rotationAnimation"];
[CATransaction commit];
}
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)finished {
if (finished)
[self rotate];
}
这将导致旋转继续,直到您指定删除动画。
CABasicAnimation班级参考
中有更多信息和选项