Skip to content

Instantly share code, notes, and snippets.

@ChrisBuchholz
Last active August 29, 2015 14:03
Show Gist options
  • Save ChrisBuchholz/7297aec644ce7ccec1e0 to your computer and use it in GitHub Desktop.
Save ChrisBuchholz/7297aec644ce7ccec1e0 to your computer and use it in GitHub Desktop.
- (UIImage *)getScreenshotOfScene:(SKScene *)scene {
[scene.view layoutIfNeeded];
scene.size = CGSizeMake(200.0, 200.0);
UIGraphicsBeginImageContextWithOptions(scene.view.bounds.size, NO, 1);
[scene.view drawViewHierarchyInRect:scene.view.frame afterScreenUpdates:YES];
UIImage *ss = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *image = [UIImage imageWithCGImage:[ss CGImage]];
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment