2

将 iOS 模拟器缩放到 100% 后,我注意到我的图标是由应用程序通过使用此代码对视图进行“截图”制作的,分辨率正常,而其他一切似乎都是视网膜分辨率:

UIGraphicsBeginImageContext(rect.size);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

任何想法如何使它成为视网膜分辨率?

4

1 回答 1

9

UIGraphicsBeginImageContext()不支持 Retina 显示。

在 iOS 4 上,您需要使用UIGraphicsBeginImageContextWithOptions()0作为最后一个参数传递,让 iOS 根据设备的屏幕分辨率自动缩放它:

UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
于 2011-05-28T03:30:54.950 回答