How do you capture only a sub-set of the entire screen using Objective-C on an iOS device?
I found the following code:
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()]
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
Which works great but I only want to create an image from a piece of the entire window. How would I go about doing that?
replace
UIGraphicsBeginImageContext(screenWindow.frame.size);
with
UIGraphicsBeginImageContext(CGSizeMake(width, height));