如何强制-drawViewHierarchyInRect:afterScreenUpdates:以@ 2x分辨率拍摄快照?

 FXHT4564_845 发布于 2023-01-29 14:58

-drawViewHierarchyInRect:afterScreenUpdates:是iOS 7中快速查看视图层次结构的快照方式.

它需要快照,但分辨率为@ 1x.iPhone 5S上的快照看起来像素化且模糊.我没有转换创建快照的视图.

我不想模糊它,并希望在屏幕上看到良好​​的质量.我是如何捕获它的:

UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我也尝试过:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.contentScaleFactor);

仍然呈现低@ 1x质量.

有没有其他方法来配置图像上下文,所以它是@ 2x分辨率?

1 个回答
  • 正确的是:

    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0f);
    

    2023-01-29 15:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有