0

I am using the following code to take a screenshot of one of my view controller, and then show it later in another view. For the UIGraphicsBeginImageContextWithOptions method, if feed it 1.0 as scale, the result image would looked blurry; but if give it 0.0 as scale, the result image would be big than the screen and would can see partial of it when show in another view. Is there a way to fix this?

CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions) {
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 1.0);
} else {
    UIGraphicsBeginImageContext(imageSize);
}

[_displayViewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];

// Retrieve the screenshot image
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
4

1 回答 1

1

实际上,如果我正在使用

UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);

图像看起来很清晰,但是此屏幕截图仅涵盖屏幕上显示的内容,而不包括隐藏在屏幕外的内容。

如果我将大小更改为 UIView 的大小,我也会遇到上述问题。

于 2012-06-08T08:28:15.337 回答