1
2
3
4
5
6
7
8
9
10
11
- (UIImage *)captureCurrentDisplayAsImage
{
    IOSurfaceRef surface = [UIWindow createScreenIOSurface];
    UIImage *surfaceImage = [[UIImage alloc] _initWithIOSurface:surface scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
    CFRelease(surface);
    return surfaceImage;
    [surfaceImage release];
}


You will need to have the headers for IODisplay setup correctly and @interfaces for the new UIWindow method + (id)createScreenIOSurface  AND  UIImage's _initWithIOSurface