Like you can see in my code, I take a screenshot and save it to the photo album.
//for retina displays
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(self.view.bounds.size);
}
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
At the beginning I used webview.size instead of self.view.bounds.size and it was working properly because the view was located at 0/0. But now I centered the WebView but the pictures is starts at 0/0 for the given size.
How can I configure that the screenshot starts at another location (e.g. 300/150) for the given size?
Or is there another way to take a picture of an UIWebView?
I solved my problem but didn’t answer the question:
I created a subclass of
UIViewand moved myUIWebViewin there, so that it is located 0/0 relative to the subclass. Then use the size of the WebView:and the other code from above.
Now you can move the subclass to every location you want.
Note: If you have labels like date/time label you have to move them too or you won’t see them on the picture.
The question is still open:
So is it possible to take a picture of a specific area of the screen?
Kind Regards. $h@rky