1. First drag some controls in the storyboard, including the UIButton control, to drag the UIButton control to the controller (method, Cutimage)
2. Call the Nstimer method in the Cutimage method
-(Ibaction) Cutimage: (UIButton *) Sender {
Nstimer *timer = [Nstimer scheduledtimerwithtimeinterval:1.0 targer:self selector: @selector (clipimage) Userinfo:nil Repeats:no];
}
3. Call the Clipimage method
-(void) clipimage
{
1. Create graphics up and down embarrassed
Uigraphicsbeginimagecontextwithoptions (self.view.bounds.size,no,0.0);
2. Pick-up Method screenshot (capture full screen)
[Self.view.layer Renderincontext:uigraphicsgetcurrentcontext ()];
3. Get the current picture
UIImage *newimage = Uigraphicsgetimagefromcurrentimagecontext ();
4. Ending the graphics context
Uigraphicsendimgecontext ();
5. Printing data
NSData *data =uiimagepngrepresentation (newimage);
[Data writetofile:@ "/user/apple/desktop/new1.png" atomically:yes];
}
iOS screenshot (code)