zoukankan      html  css  js  c++  java
  • 【读书笔记】iOS-截屏功能的实现。

    一,整个工程文件。

     

     

    二,代码

    ViewController.m

    复制代码
    #import "ViewController.h"
    #import <QuartzCore/QuartzCore.h>
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
    }
    #pragma -mark -doClickActions
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [self screenShot];
    }
    #pragma -mark -functions
    //截屏功能
    -(void) screenShot
    {
        
        UIGraphicsBeginImageContext(self.view.bounds.size);
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        
        UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        NSLog(@"image:%@",image);
        
        UIImageView *imaView = [[UIImageView alloc] initWithImage:image];
        imaView.frame = CGRectMake(0, 700, 500, 500);
        [self.view addSubview:imaView];
        
        UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
        
    }
    复制代码

     

     

     
     
  • 相关阅读:
    ansible-思维导图
    linux运维面试精华题
    python博客大全
    python-常用代码
    男孩周末班-k8s-架构图
    jQuery操作
    js点击事件,添加或删除元素,定时器
    js.DOM操作
    js数组,阶乘,递归,冒泡排序
    js匿名和自执行函数,控制语句
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/4725259.html
Copyright © 2011-2022 走看看