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

    一。整个project文件。

     

     

    二,代码

    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);
        
    }
    复制代码

     


  • 相关阅读:
    windows wmi
    python编码规范
    gogs安装
    mariadb-5.5安装
    python kafka
    delimiter关键字
    phpstorm设置背景图片
    linux 下mysql 关闭 启动
    通过下载git包来安装git
    git clone 某个链接时候报错Initialized empty Git repository in 不能克隆
  • 原文地址:https://www.cnblogs.com/brucemengbm/p/6953521.html
Copyright © 2011-2022 走看看