//frame 是你所需要的区域大小
+(UIImage *)screenshotsImageFram:(CGRect)frame{
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);//全屏截图,包括window
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect1 =frame;
UIImage * image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([viewImage CGImage], rect1)];
return image;
}