One. The entire project file.
Two, the code
Viewcontroller.m
#import "ViewController.h"#import<QuartzCore/QuartzCore.h>@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.}#pragma-mark-doclickactions-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{[self screenshot];}#pragma-mark-functions//Screen cutting function-(void) screenshot{Uigraphicsbeginimagecontext (self.view.bounds.size); [Self.view.layer Renderincontext:uigraphicsgetcurrentcontext ()]; UIImage*image=Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); NSLog (@"image:%@", image); Uiimageview*imaview =[[Uiimageview alloc] initwithimage:image]; Imaview.frame= CGRectMake (0, the, -, -); [Self.view Addsubview:imaview]; Uiimagewritetosavedphotosalbum (image, self, nil, nil); }
"Reading notes" ios-screenshot function implementation.