<分区>
<分区>
我想要实现的是在我的应用程序中截取屏幕截图,它运行良好,但质量很差,而且屏幕截图的尺寸也非常小。我也尝试像裁剪顶部一样裁剪图像的底部,但我看不到可以在何处为底部添加尺寸。有一个更好的方法吗?我正在使用下面的代码:
// Define the dimensions of the screenshot you want to take (the entire screen in this case)
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//now we will position the image, X/Y away from top left corner to get the portion we want
UIGraphicsBeginImageContext(self.view.frame.size);
[sourceImage drawAtPoint:CGPointMake(0, -10)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage,nil, nil, nil);
感谢您的回答。
最佳答案
替换
UIGraphicsBeginImageContext(self.view.bounds.size);
与
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
关于ios - 在不损失质量的情况下在 Objective-C 中截取屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24050262/