And*_*rew 2 iphone objective-c retina-display
在将iOS模拟器缩放到100%之后,我注意到应用程序通过使用此代码拍摄视图的"屏幕截图"而制作的图标处于正常分辨率,而其他所有图标都显示在视网膜分辨率中:
UIGraphicsBeginImageContext(rect.size);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
任何想法如何使其在视网膜分辨率?
UIGraphicsBeginImageContext() 不是Retina显示器.
在iOS 4上,您需要使用UIGraphicsBeginImageContextWithOptions(),0作为最后一个参数传递,让iOS根据设备的屏幕分辨率自动缩放它:
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
944 次 |
| 最近记录: |