如何在iOS设备上使用Objective-C仅捕获整个屏幕的子集?
我找到了以下代码:
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()]
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
哪个效果很好,但我只想从整个窗口的一部分创建一个图像。我该怎么做呢?
答案 0 :(得分:-1)
替换
UIGraphicsBeginImageContext(screenWindow.frame.size);
与
UIGraphicsBeginImageContext(CGSizeMake(width,height));