Reputation: 14513
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();
Upvotes: 0
Views: 475
Reputation: 181
Actually if I'm using
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
The image looks clear, however this screenshot will only cover whats shown on the screen and not those hidden off screen.
If I change the size to that of an UIView, the above problem occurs to me as well.
Upvotes: 1