• 屏幕截图


    1、获得屏幕图像

    - (UIImage *)imageFromView: (UIView *) theView

    {

        

        UIGraphicsBeginImageContext(theView.frame.size);

        CGContextRef context = UIGraphicsGetCurrentContext();

        [theView.layer renderInContext:context];

        UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        

        return theImage;

    }

    //获得某个范围内的屏幕图像

    - (UIImage *)imageFromView: (UIView *) theView   atFrame:(CGRect)r

    {

        UIGraphicsBeginImageContext(theView.frame.size);

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSaveGState(context);

        UIRectClip(r);

        [theView.layer renderInContext:context];

        UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        

        return  theImage;//[self getImageAreaFromImage:theImage atFrame:r];

    }

    2、将图像保存到图库中

       UIImageWriteToSavedPhotosAlbum([imageView image], nilnil,nil);

           UIAlertView *alert = [[UIAlertView allocinitWithTitle:@"存储照片成功"

                                                     message:@"您已将照片存储于图片库中,打开照片程序即可查看。"

                                                     delegate:self

                                             cancelButtonTitle:@"OK"

                                             otherButtonTitles:nil];

           [alert show];

           [alert release];

  • 相关阅读:
    IDEA 远程调试springboot
    Mybatitas-plus实现逻辑删除
    java通过poi导出excel
    js 展示当前时间
    Linux环境下服务自启
    Spring自带定时器@Scheduled
    Quartz任务调度框架相关方法、参数理解
    Quartz 实现定时任务
    mysql 使用union(all) + order by 导致排序失效
    mongodb的查询操作
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3437153.html
Copyright © 2020-2023  润新知