这应该很简单,但我在旋转一个UIImageView
一整圈360度并且永久重复的时候遇到了困难。
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState animations:^{
self.reloadButton.imageView.transform = CGAffineTransformRotate(self.reloadButton.imageView.transform, -M_PI);
} completion:^(BOOL finished) {
}];
根据文档,我传递给 CGAffineTransformRotate
的角度的有无符号决定了旋转的方向,但上述代码是逆时针旋转的。同样适用于M_PI
。
这个矩阵通过弧度值来旋转坐标系轴。在 iOS 中,正值表示逆时针旋转,负值表示顺时针旋转。在 Mac OS X 中,正值表示顺时针旋转,负值表示逆时针旋转。