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();

    });

}

posted @ 2015-04-16 12:02  花园晓雨  阅读(118)  评论(0编辑  收藏  举报