截取指定区域
//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;
}
有疑问可以联系我哦 1165300131