How to force -drawViewHierarchyInRect:afterScreenUpdates: to take snapshots at @2x resolution?
core-graphics, ios, ios7, ipad, iphone
Solution
The correct one would be:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0f);
Problem
`-drawViewHierarchyInRect:afterScreenUpdates:` is a fast way in iOS 7 to take a snapshot of a view hierarchy. It takes snapshots but with @1x resolution. The snapshots look pixellated and blurry on an iPhone 5S. The view from which I create a snapshot is not transformed. I don't want to blur it and want good quality as seen on screen. Here is how I capture it: ``` UIGraphicsBeginImageContext(self.bounds.size); [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); ``` I also tried: ``` UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.contentScaleFactor); ``` which still renders with low @1x quality. Is there another way to configure the image context so it's @2x resolution?