iOS 画图 截图

来源:互联网 发布:涤纶低弹网络丝应香莲 编辑:程序博客网 时间:2024/05/22 09:02

//

//  ViewController.m

//  touchSCHEvent

//

//  Created by tianshangrenjian on 15/6/29.

//  Copyright (c) 2015 tianshangrenjian. All rights reserved.

//


#import "ViewController.h"

#import "SCHView.h"


@interface ViewController ()


@property (weak, nonatomic) IBOutletSCHView *schView;

- (IBAction)clearPic:(id)sender;

@end


@implementation ViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    UIImagePickerController *vc;

    vc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

    vc.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;

}


- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

/*

 鼠标点击的时候触发产生的事件

 

 

 */

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

   

}

//如果要截屏用self.view即可

- (IBAction)savepic:(id)sender {

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{

        

        UIGraphicsBeginImageContext(self.schView.frame.size);//尺寸

    CGContextRef ctx=UIGraphicsGetCurrentContext();

    [self.view.layerrenderInContext:ctx];//图像层

    UIImage *img=UIGraphicsGetImageFromCurrentImageContext();

    UIImageWriteToSavedPhotosAlbum(img,nil, nil, nil);

    UIGraphicsEndImageContext();

    


    });

    

        

    

}

- (IBAction)undopic:(id)sender {

     [self.schViewundo];

}

- (IBAction)clearPic:(id)sender {

    [self.schViewclear];

}

@end


0 0
原创粉丝点击