Problem about @2X
1.I use below code for take screenshot.is it necessary to change it for开发者_运维技巧 high resolution
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
2.what does happen if i just use one image with 640*960 resolution for both low and high quality ? (means that don't use image with @2x)
That will only take normal (320x480) resolution screenshots. So in answer to 1, yes. Older generation devices can do double resolution too, the screen just can't display it.
To take a screenshot at the res of the device you can do this:
CGSize size = self.view.bounds.size;
CGFloat scale = 1.0f;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
scale = [[UIScreen mainScreen] scale];
size = CGSizeApplyAffineTransform(size, CGAffineTransformMakeScale(scale, scale));
}
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);
[self.view.layer renderInContext:context];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Taking double res on older devices does work, and will be scaled back down if displayed on screen. But is not recommended, and simply a waste.
精彩评论