iOS截图

- (void)cutGloable {

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

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

        

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

        

        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        

        NSData *data = UIImagePNGRepresentation(newImage);

        [data writeToFile:@"路径/图片名.png" atomically:YES];

        

        UIGraphicsEndImageContext();

    });

}

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