UItableView 所有内容保存为图片
2024-09-05 06:46:33
将所有的UITableView保存为图片,因为UITableView只能保存显示当前,所以,就单个保存后,合并为一张图片
代码如下:
-(IBAction)savePic:(id)sender { //支持retian高分辨率 UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, 0.0); float curH = mTableView.contentSize.height; UIImageView *allView = [[UIImageView alloc]initWithFrame:CGRectMake(, , , curH)]; for (float f = ; f < curH; f+=) { mTableView.contentOffset = CGPointMake(, f); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImageView *imgV = [[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]; imgV.frame = CGRectMake(, f, , ); [allView addSubview:imgV]; [imgV release]; } UIGraphicsEndImageContext(); //保存图片 UIGraphicsBeginImageContextWithOptions(allView.frame.size, YES, 0.0); [allView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [allView release]; [UIImagePNGRepresentation(img) writeToFile:@"/users/test/desktop/font.png" atomically:YES]; }
最新文章
- angular 路由请求js文件
- 使用JQuery Ajax请求,在Controller里获取Session
- 油田 Oil Deposits
- 一个快速、完善的Android开发框架整合实践(QuickAndroid)
- 【Struts 2】Struts2环境搭建
- FE: Responsive Web Design Overview
- DSR on Openstack POC
- sqlserver 注释提取工具
- 日常:css样式、选择器、个别知识点、数组array
- VMware的安装和使用
- IIS启动应用程序池报错";服务无法在此时接受控制信息";
- iOS学习——(转)NSObject详解
- cf1088E Ehab and a component choosing problem (树形dp)
- 【转】Centos7安装nodejs
- 集合框架-Collection与List集合
- flask-数据库模型设计2
- DNS必知必会
- css选择器,样式表导入
- 基于FPGA的异步FIFO验证
- Android Proguard使用技巧