我想以90度旋转图像(左右旋转)。我正在使用以下代码以360度向左旋转图像。我如何以90度旋转我的图像。
-(IBAction)btnLeftRotateClicked:(id)sender
{
CATransform3D rotationTransform = CATransform3DMakeRotation(1.0f * M_PI, 0, 0, 1.0);
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
rotationAnimation.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation.duration = 0.25f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1;
[imageAdjustView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
谢谢。
最佳答案
如果只想以2D旋转图像,为什么不使用affineTransform
CGAffineTransformMakeRotation(-M_PI * 0.5);