zoukankan      html  css  js  c++  java
  • 截取屏幕并保存到本地

     /* Capture the screenshot */
        UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0.0f);

        if ([self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES]){
            NSLog(@"Successfully draw the screenshot.");
        } else {
            NSLog(@"Failed to draw the screenshot.");
        }
        UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        
        /* Save it to disk */
        NSFileManager *fileManager = [[NSFileManager alloc] init];
        NSURL *documentsFolder = [fileManager URLForDirectory:NSDocumentDirectory
                                                     inDomain:NSUserDomainMask
                                            appropriateForURL:nil
                                                       create:YES
                                                        error:nil];
        NSURL *screenshotUrl = [documentsFolder
                               URLByAppendingPathComponent:@"screenshot.png"];
        
        NSData *screenshotData = UIImagePNGRepresentation(screenshot);
        
        if ([screenshotData writeToURL:screenshotUrl atomically:YES]){
            NSLog(@"Successfully saved screenshot to %@", screenshotUrl);
        } else {
            NSLog(@"Failed to save screenshot.");
        }

  • 相关阅读:
    finalshell连接工具
    oracle11g R2数据库的迁移(同windows系统迁移)使用RMAN
    《python可以这样学》第一章
    python环境开发
    HTTP下帐号密码的截取
    Kail Linux下载与安装
    查看Linux系统内存、CPU、磁盘使用率和详细信息
    内网获取目标的浏览过的所有图片
    修改kali软件源并配置网络
    Python迭代器与生成器
  • 原文地址:https://www.cnblogs.com/NSNULL/p/4629556.html
Copyright © 2011-2022 走看看