-drawViewHierarchyInRect:afterScreenUpdates:
是 fast way在 iOS 7 中拍摄 View 层次结构的快照。
它拍摄快照,但分辨率为@1x。这些快照在 iPhone 5S 上看起来像素化且模糊。我从中创建快照的 View 未转换。
我不想模糊它,想要在屏幕上看到的高质量。 以下是我如何捕获它:
UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我也试过:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.contentScaleFactor);
仍然以低 @1x 质量呈现。
是否有另一种方法来配置图像上下文使其达到@2x 分辨率?
最佳答案
正确的应该是:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0f);
关于ios - 如何强制-drawViewHierarchyInRect :afterScreenUpdates: to take snapshots at @2x resolution?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21550518/