• 保存视图的截图方法


    记录一下:

    - (void)save
    {
        //把图片保存到系统相册
        //把UIView上面的绘制的内容生成一张图片.保存.
        UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        //把画板上的东西绘制到上下文当中
        [self.view.layer renderInContext:ctx];
        //从上下文当中生成一张图片
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        //关闭上下文
        UIGraphicsEndImageContext();
        //把生成的图片保存到系统相册
        //注意:保存图片成功必须得要调用下面方法.
        //    image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
        UIImageWriteToSavedPhotosAlbum(newImage, self, @selector(image:didFinishSavingWithError: contextInfo:), nil);
    }
    
    //保存图片成功时调用
    - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *) contextInfo
    {    
        NSLog(@"保存完成");
    }
    
  • 相关阅读:
    python模块导入
    linux总结shell
    linux和shell关系
    gdb调试工具
    C语言.c和.h
    CSS cursor 属性
    html dom SetInterVal()
    css hover伪类选择器与JQuery hover()方法
    CSS 清除浮动 clear 属性
    block,inline和inline-block概念和区别
  • 原文地址:https://www.cnblogs.com/110-913-1025/p/9261657.html
Copyright © 2020-2023  润新知