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(@"保存结束");

}

原文地址:https://www.cnblogs.com/iOS771722918/p/4850417.html