我想旋转一个UIImageView,而我使用此代码:旋转的UIImageView
-(IBAction)rotateImageView:(id)sender{
photoView.transform = CGAffineTransformMakeRotation(M_PI); //rotation in radians
}
代码工作。当我按下按钮时,图像旋转180度,但如果再次按下它,它不会旋转回原来的位置,但它保持不动。为什么??
我想旋转一个UIImageView,而我使用此代码:旋转的UIImageView
-(IBAction)rotateImageView:(id)sender{
photoView.transform = CGAffineTransformMakeRotation(M_PI); //rotation in radians
}
代码工作。当我按下按钮时,图像旋转180度,但如果再次按下它,它不会旋转回原来的位置,但它保持不动。为什么??
因为你申请同一再次变换到视图,而没有考虑到任何现有的转变。
试试这个:
photoView.transform = CGAffineTransformRotate(photoView.transform,M_PI);
你必须从当前的旋转旋转的ImageView,使其原来的
使用此代码
CGAffineTransformRotate(photoView.transform, M_PI);
由于某种原因,这样做: - (IBAction为)rotateImageView:(ID)发送{ CGAffineTransformRotate(photoView.transform,M_PI); }不起作用 – Alessandro
对不起,我忘了添加作业。 – Alex