我正在使用以下代码捕获应用程序当前显示的屏幕的一部分:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContext(CGSizeMake(320, 320));
[sourceImage drawAtPoint:CGPointMake(0, -45)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
问题是,与原始屏幕相比,结果降低了质量。如何防止质量损失?