2

iOSシミュレーターを100%までズームした後、このコードを使用してビューの「スクリーンショット」を撮ることによってアプリによって作成されたアイコンが通常の解像度であるのに対し、他のすべては網膜の解像度であるように見えることに気付きました。

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

網膜の解像度にする方法はありますか?

4

1 に答える 1

9

UIGraphicsBeginImageContext()Retinaディスプレイ対応ではありません。

UIGraphicsBeginImageContextWithOptions()iOS 4では、代わりにを使用する必要があります。0最後の引数として、iOSがデバイスの画面解像度に基づいて自動的にスケーリングするようにします。

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