//
// 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) IBOutlet SCHView *schView;
- (IBAction)clearPic:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImagePickerController *vc;
vc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
vc.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// 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.layer renderInContext:ctx];//图像层
UIImage *img=UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
UIGraphicsEndImageContext();
});
}
- (IBAction)undopic:(id)sender {
[self.schView undo];
}
- (IBAction)clearPic:(id)sender {
[self.schView clear];
}
@end