- (UIImage *)captureScreenWithSize:(CGRect )rect
{
UIImage *image = nil;
// 截图
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([image CGImage], rect)]; // 裁剪部分区域
return image;
}
iOS 截图
最新推荐文章于 2021-10-29 15:29:38 发布