2013-07-16 1 views
-2

와 함께 스크린 샷을 가지고 나는 아이폰 OS는 - 상태 표시 줄

+ (UIImage *)screenshot { 
    CGSize imageSize = [[UIScreen mainScreen] bounds].size; 
    if (NULL != UIGraphicsBeginImageContextWithOptions) { 
     UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 
    } else { 
     UIGraphicsBeginImageContext(imageSize); 
    } 

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    for (UIWindow *window in [[UIApplication sharedApplication] windows]) { 
     if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) { 

      CGContextSaveGState(context); 

      CGContextTranslateCTM(context, [window center].x, [window center].y); 

      CGContextConcatCTM(context, [window transform]); 

      CGContextTranslateCTM(context, 
            -[window bounds].size.width * [[window layer] anchorPoint].x, 
            -[window bounds].size.height * [[window layer] anchorPoint].y); 


      [[window layer] renderInContext:context]; 


      CGContextRestoreGState(context); 
     } 
    } 


    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

    UIGraphicsEndImageContext(); 
    return image; 
} 

그러나, 나는 그것으로 하나의 작은 문제가 ... 사과 문서에서이 코드를 얻을. 내 스크린 샷에 상태 표시 줄을 포함시키고 싶습니다. 어떻게해야합니까? 아니면이 작업을 수행하는 더 좋은 방법이 있습니까? 그것을 할 수있는 가장 좋은 방법입니다 앱 스토어 승인 가능한 아니지만 여기에 헨리

+0

@livingtech Ooops. 죄송합니다. 내가 검토해볼 께. –

답변

-1

+ (UIImage *)screenshot { 

    CGImageRef screen = UIGetScreenImage(); 
    UIImage *image = [UIImage imageWithCGImage:screen]; 
    CGImageRelease(screen); 

    return image; 
} 

... 내가이 일을 결국 방법입니다.

+1

놀랍지 만 UIGetScreenImage는 개인용 API이므로 앱 스토어에서 허용하지 않습니다. 어떻게 특정 영역 스크린 샷을 찍을 수 있습니까? – Suge