iOS中的截屏

 

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

    UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, 0.0);

    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();

    UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

}

 

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo

{

    NSLog(@"保存结束");

}

 

 

posted @ 2015-09-30 22:03  花园晓雨  阅读(153)  评论(0编辑  收藏  举报