This article turns from http://blog.sina.com.cn/s/blog_801997310101a769.html
Intercept this area (Self.view):
Uigraphicsbeginimagecontext (Cgsizemake (Self.view.frame.size.width, self.view.frame.size.height));
[Self.view.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *viewimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
Uiimagewritetosavedphotosalbum (viewimage, nil, nil, nil);
Full Screen:
UIWindow *screenwindow = [[UIApplication sharedapplication] Keywindow];
Uigraphicsbeginimagecontext (screenWindow.frame.size);
[Screenwindow.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *viewimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
Uiimagewritetosavedphotosalbum (viewimage, nil, nil, nil);
The above 2 methods can be run by both the real machine and the simulator. You can see the pictures in the Photo.app.
Apple's latest Open Interface function (full screen) has already been tried and will not reject:
Cgimageref Uigetscreenimage ();
Cgimageref img = uigetscreenimage ();
uiimage* Scimage=[uiimage imagewithcgimage:img];
Uiimagewritetosavedphotosalbum (scimage, nil, nil, nil);
It still works,but only On-device (not in simulator).
Save as specified name:
UIWindow *screenwindow = [[UIApplication sharedapplication] Keywindow];
Uigraphicsbeginimagecontext (screenWindow.frame.size);
[Screenwindow.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *screenshot = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
NSData *screenshotpng = uiimagepngrepresentation (screenshot);
Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *documentsdirectory = [Paths objectatindex:0];
Nserror *error = nil;
[Screenshotpng writetofile:[documentsdirectory stringbyappendingpathcomponent:@ "screenshot.png"] options: Nsatomicwrite error:&error];
Part of the code from: Http://stackoverflow.com/questions/692464/emailing-full-screen-of-iphone-app
There is no ipad real-release app can use this method to make a transparent button point, haha.
Intercept this area (Self.view):
Uigraphicsbeginimagecontext (Cgsizemake (Self.view.frame.size.width, self.view.frame.size.height));
[Self.view.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *viewimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
Uiimagewritetosavedphotosalbum (viewimage, nil, nil, nil);
Full Screen:
UIWindow *screenwindow = [[UIApplication sharedapplication] Keywindow];
Uigraphicsbeginimagecontext (screenWindow.frame.size);
[Screenwindow.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *viewimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
Uiimagewritetosavedphotosalbum (viewimage, nil, nil, nil);
The above 2 methods can be run by both the real machine and the simulator. You can see the pictures in the Photo.app.
Apple's latest Open Interface function (full screen) has already been tried and will not reject:
Cgimageref Uigetscreenimage ();
Cgimageref img = uigetscreenimage ();
uiimage* Scimage=[uiimage imagewithcgimage:img];
Uiimagewritetosavedphotosalbum (scimage, nil, nil, nil);
It still works,but only On-device (not in simulator).
Save as specified name:
UIWindow *screenwindow = [[UIApplication sharedapplication] Keywindow];
Uigraphicsbeginimagecontext (screenWindow.frame.size);
[Screenwindow.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *screenshot = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
NSData *screenshotpng = uiimagepngrepresentation (screenshot);
Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *documentsdirectory = [Paths objectatindex:0];
Nserror *error = nil;
[Screenshotpng writetofile:[documentsdirectory stringbyappendingpathcomponent:@ "screenshot.png"] options: Nsatomicwrite error:&error];
(GO) iOS intercept screen code