UIGraphicsGetImageFromCurrentImageContext()视网膜分辨率?

sud*_*-rf 36 iphone cocoa-touch

我正在拍摄我的屏幕并使用它来操纵它UIGraphicsGetImageFromCurrentImageContext().一切都很好.然而,在iPhone 4上,分辨率看起来很破旧,因为它使用的图像似乎是标准分辨率,而不是@ 2x.有没有办法提高结果图像的分辨率?

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

Mar*_*ote 90

您应该使用UIGraphicsBeginImageContextWithOptions哪个允许您设置比例因子.使用比例因子0.0f来使用设备的比例因子.

  • 对于将来看到这个的人,这仅适用于iOS 4+. (4认同)