在我的应用程序中,我使用了一种截屏方法。在我的iPad 2上,执行此方法非常快(约130毫秒)。但是在新的iPad上(肯定是由于更高的分辨率和相同的CPU),执行时间需要大约700毫秒!有没有办法优化我的方法?也许有一种方法可以直接使用图形卡来处理?以下是我的截屏方法:
- (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;
感谢您的帮助。
}