//1.首先在storyboard中拖一些控件,包括UIButton控件,将UIButton控件拖线到控制器中(方法、CutImage)
//2.在CutImage方法中调用NSTimer方法
- (IBAction)CutImage:(UIButton *)sender {
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 targer:self selector:@selector(clipImage) userInfo:nil repeats:NO];
}
//3.调用clipImage方法
-(void)clipImage
{
//1.创建图形上下为难
UIGraphicsBeginImageCOntextWithOptions(self.view.bounds.size,NO,0.0);
//2.调取方法截屏(截取的是全屏)
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
//3.获得当前的图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//4.结束图形上下文
UIGraphicsEndImgeContext();
//5.打印数据
NSData *data =UIImagePNGRepresentation(newImage);
[data writeToFile:@"/User/apple/DeskTop/new1.png" atomically:YES];
}