내 앱에서 스크린 샷 방법을 사용하고 있습니다. 내 iPad 2에서는이 방법을 실행하는 것이 매우 빠릅니다 (약 130ms). 하지만 새로운 iPad (확실히 높은 해상도와 동일한 CPU로 인해)에서 700 밀리 초를 취하고 있습니다! 방법을 최적화 할 수있는 방법이 있습니까? 아마도 그래픽 카드로 직접 작업 할 수있는 방법이 있을까요? 당신의 도움에 대한iPad 3 느린 스크린 샷
- (UIImage *)image {
CGSize imageSize = self.bounds.size;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(imageSize, NO, [UIScreen mainScreen].scale);
else UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, [self center].x, [self center].y);
CGContextConcatCTM(context, [self transform]);
CGContextTranslateCTM(context, -[self bounds].size.width * [[self layer] anchorPoint].x, -[self bounds].size.height * [[self layer] anchorPoint].y);
[[self layer] renderInContext:context];
CGContextRestoreGState(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
감사 :
여기 내 스크린 샷 방법입니다.
여기 도와 드릴 수 없습니다. 그러나 나는 700ms가 정말로 느리다 고 생각한다. 130ms * 4 = 520ms와 같지 않아야합니까? –
'UIGraphicsBeginImageContextWithOptions (imageSize, NO, [UIScreen mainScreen] .scale);'대신'UIGraphicsBeginImageContextWithOptions (imageSize, NO, 0.0f);를 사용해보세요. 1 : 1 스크린 샷을 만듭니다. 아니면'[UIScreen mainScreen] .scale'이 필요한 특별한 이유가 있습니까? –
@ Jenox 예, 그렇지만 700ms와 비슷합니다. – Pierre