0
我添加了缩放以将手势旋转到UIImageView(myImageView)。缩放和旋转后,有应用按钮保存图像。以下是应用方法。它以正确的旋转和缩放来正确保存图像。就像截图一样。图像在缩放和旋转后根据UIImage的框架未显示
UIGraphicsBeginImageContextWithOptions(view.frame.size,view.opaque,0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImageJPEGRepresentation(viewImage, 100);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *strPath = [documentsDirectory stringByAppendingPathComponent:@"BorderedImage.jpg"];
[data writeToFile:strPath atomically:YES];
但这样做后,我将保存的图像重新分配给myImageView。
myImageView.image=[self loadImage:@"BorderedImage.jpg"];
它做什么,如果图像缩小,图像变得更小,如果图像放大,图像变得太大。如果图像旋转,则图像显示的旋转完全错误。
我知道这是某种UIImageView问题,因为我检查了文档文件夹中的图像,它就像我按下应用按钮时一样。
我是iOS开发新手。请帮助我。