将html转换为ios中的图像 [英] converting html to image in ios

查看:243
本文介绍了将html转换为ios中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用多个.html文件并在webview中打开它,我也需要将html页面显示为拇指视图,是否可以将html页面转换为图像或任何其他方法以显示将html文件作为预览。请帮助我,如果有人知道

I am using multiple .html files in my app and opens it in a webview , i need to show the html pages as a thumb view as well , is it possible to convert the html pages into images or any other methods to show the html files as a preview. Please help me if any one know

推荐答案

-(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
}

这篇关于将html转换为ios中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆