问题
I want to take a snapshot of a view (WebView) or, if that is not possible, the whole screen, so I can save it into the user's photo gallery. I was wondering if this is possible.
回答1:
To get the image, you'll want to use:
UIGraphicsBeginImageContext(self.bounds.size);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Then, to save to the Photos Library:
UIImageWriteToSavedPhotosAlbum(viewImage,nil,NULL,NULL);
来源:https://stackoverflow.com/questions/501496/take-snapshot-of-view-webview-programmatically