Convert UIWebview contents to a UIImage when the webview is larger than the screen

Very similar to this question (and also this answer), I'm trying to make an UIImage out from a webview. So far I'm using the code suggested in the answer, specifically:

UIGraphicsBeginImageContext(webview.bounds.size);
[webview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

However, when the contents of the webview are larger than the screen, the resulting images are not complete and have missing patches. Any ideas on how to fix this?

7
задан Community 23 May 2017 в 12:09
поделиться