Hi all,
I’m trying to figure out how to get a screenshot (don’t need to save it, just store it in a variable) within xCode (not within Unity).
The img variable just returns a white screen, so I’m thinking the code below isn’t accessing the right view / window.
Does anyone have any ideas how to get the screen as a UIImage within xCode?
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect rect = [keyWindow bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Any help would be greatly appreciated.