问题描述
||
将iOS模拟器放大至100%后,我注意到由我使用该代码通过对视图的“屏幕截图”进行“截屏”制作的图标均处于正常分辨率,而其他所有内容似乎都在视网膜分辨率:
UIGraphicsBeginImageContext(rect.size);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
任何想法如何使其成为视网膜分辨率?
解决方法
UIGraphicsBeginImageContext()
不支持Retina显示。
在iOS 4上,您需要改用UIGraphicsBeginImageContextWithOptions()
,将0
作为最后一个参数传递,以使iOS根据设备的屏幕分辨率自动缩放它:
UIGraphicsBeginImageContextWithOptions(rect.size,NO,0);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();