将所有的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];

}

最新文章

  1. angular 路由请求js文件
  2. 使用JQuery Ajax请求,在Controller里获取Session
  3. 油田 Oil Deposits
  4. 一个快速、完善的Android开发框架整合实践(QuickAndroid)
  5. 【Struts 2】Struts2环境搭建
  6. FE: Responsive Web Design Overview
  7. DSR on Openstack POC
  8. sqlserver 注释提取工具
  9. 日常:css样式、选择器、个别知识点、数组array
  10. VMware的安装和使用
  11. IIS启动应用程序池报错&quot;服务无法在此时接受控制信息&quot;
  12. iOS学习——(转)NSObject详解
  13. cf1088E Ehab and a component choosing problem (树形dp)
  14. 【转】Centos7安装nodejs
  15. 集合框架-Collection与List集合
  16. flask-数据库模型设计2
  17. DNS必知必会
  18. css选择器,样式表导入
  19. 基于FPGA的异步FIFO验证
  20. Android Proguard使用技巧

热门文章

  1. js之数组知识
  2. CSS盒模型总结(一)
  3. LeetCode 买卖股票的最佳时机
  4. Linux菜鸟起飞之路【二】Linux基本常识
  5. ST3使用
  6. 如何把握好 transition 和 animation 的时序,创作描边按钮特效
  7. jsDate()
  8. 2019年6月14日 Web框架之Django_07 进阶操作(MTV与MVC、多对多表三种创建方式、前后端传输数据编码格式contentType、ajax、自定义分页器)
  9. Django中重定向页面的时候使用命名空间
  10. Python学习网站推荐