ios - 如何强制-drawViewHierarchyInRect :afterScreenUpdates: to take snapshots at @2x resolution?

标签 ios iphone ipad ios7 core-graphics

-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/

相关文章:

iPhone StoreKit - 无效的产品 ID

iOS - 在编码中而不是在 XIB 或 Storyboard 中的 UI 设计是否可行?

iphone - iOS 开发 : Push notifications prevent my local notifications from firing

ios - 具有主从 View 的 Xcode 模拟器

ios - UIFont 等宽数字+小型大写字母

ios - Swift - 使用导航栏和标签栏获取 viewController 的大小

iphone - (NSError**)error 有什么意义?

ios - 如何在 iOS 中为模拟器和设备 (IPA) 构建框架

ios - 添加到 tableview 单元格的按钮也出现在其他随机单元格上

ios - 从浮点 lat long 创建的 CLLocation 显示出更高的精度