1
我在我的应用程序中使用了多个.html文件,并在webview中打开它,我也需要将html页面显示为拇指视图,是否可以将html页面转换为图像或任何其他方法来显示HTML文件作为预览。请帮助我,如果有人知道将html转换为ios中的图像
我在我的应用程序中使用了多个.html文件,并在webview中打开它,我也需要将html页面显示为拇指视图,是否可以将html页面转换为图像或任何其他方法来显示HTML文件作为预览。请帮助我,如果有人知道将html转换为ios中的图像
-(void) webViewDidFinishLoad:(UIWebView *)webView {
UIGraphicsBeginImageContext(CGSizeMake(webView.layer.frame.size.width, webView.layer.frame.size.height));
[webView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContext(CGSizeMake(70,100));
[image drawInRect:CGRectMake(0, 0, 70,100)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//image is now a 70x100 thumbnail. make sure you include CoreGraphics
}
我在这里得到一个空白图片?? – vishnu
这适用于我。你确定你的web视图已经完成加载,并且当它缩小时不会变成黑色图像吗? – Bergasms