Last active
August 29, 2015 14:08
-
-
Save JaniJegoroff/fef4dc983780f2797dae to your computer and use it in GitHub Desktop.
Calabash backdoor method to capture screenshot and save it to Photos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)takeScreenShot:(NSString *)aIgnore | |
{ | |
UIViewController* viewController = (UIViewController*) self.window.rootViewController; | |
UIGraphicsBeginImageContextWithOptions(viewController.view.bounds.size, viewController.view.opaque, 0.0); | |
[viewController.view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
NSData *imageData = UIImagePNGRepresentation(image); | |
[imageData writeToFile:@"shot.PNG" atomically:YES]; | |
UIImageWriteToSavedPhotosAlbum(image, nil, NULL, NULL); | |
return @"true"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):005:0> backdoor('takeScreenShot', '') | |
"true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.screencast.com/t/jsm9x8Z9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment