ios - 捏和旋转手势结束后如何将图像设置为原始状态?

标签 ios objective-c

我增加了旋转和捏手势的功能,但是手势结束后,我希望我的图像恢复到原始状态。

这是我的函数处理旋转手势的代码

-(void)handlerotation:(UIRotationGestureRecognizer *)roatategesture
{
   if(roatategesture.state==UIGestureRecognizerStateEnded) 
   {
    roatategesture.rotation = 0.0;
    return;
   }
   self.myimage.transform = CGAffineTransformRotate(self.myimage.transform, roatategesture.rotation);
   roatategesture.rotation=0.0;
}

最佳答案

用这个:

if(roatategesture.state==UIGestureRecognizerStateEnded) {
    roatategesture.rotation = 0.0;
    self.myimage.transform = CGAffineTransformIdentity;
    return;
}

关于ios - 捏和旋转手势结束后如何将图像设置为原始状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32780674/

相关文章:

iphone - 如何访问我在相机应用程序中保存的照片的相册?

ios - 在 UIAlertView 覆盖上方添加按钮

iphone - UIButton 不调用目标的选择器

ios - 删除字母大写键盘

ios - 多个对象等待相同的 API 响应

ios - 将数据从 UIViewController 传递到 AppDelegate

ios - 在 Cordova iOS 包中找不到 `OBJROOT="$OBJROOT"` 来尝试修复构建错误 : xcodebuild: Command failed with exit code 65

iphone - 如何为 UILabel 复制?

ios - 由于信号段错误 11 Xcode 9 - iOS 模拟器,命令失败

ios - UICollectionView 类似 iPhone 照片应用的点击动画