我在我的应用程序中截取屏幕截图。我可以截取屏幕截图,但现在 我想通过指定x和y坐标来实现它。我的意思是从y = 40拍摄截图。这可能吗?
UIGraphicsBeginImageContext(screenshot.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
答案 0 :(得分:0)
UIGraphicsBeginImageContext(screenshot.frame.size);
CGImageRef imageRef = CGImageCreateWithImageInRect((CGImageRef)self.view.layer.contents, cropRect);
UIImage *image = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
[image drawInRect:CGRectMake(...)];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();