7

UIViewのスクリーンショットを撮ってPDFを作成しています。これは現在、Retinaディスプレイを搭載したiPad3でうまく機能していますが、低解像度の画面を備えた他のデバイスでテストすると、テキストの解像度に問題があります。

これが私のコードです:

    //start a new page with default size and info
    //this can be changed later to include extra info.
    UIGraphicsBeginPDFPage();

    //render the view's layer into an image context
    //the last option specifies scale. If 0, it uses the devices scale.
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 2.0);

    CGContextRef context = UIGraphicsGetCurrentContext();
    [view.layer renderInContext:context];
    UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    //render the screenshot into the pdf page CGContext
    [screenShot drawInRect:view.bounds];

    //close the pdf context (saves the pdf to the NSData object)
    UIGraphicsEndPDFContext();

UIGraphicsBeginImageContextWithOptionsまた、スケールを2.0に設定しようとしましたが、変更はありません。iPad2のビューを2倍の解像度で強制的にレンダリングするにはどうすればよいですか?

期待される出力:

Imgur

実際の出力:

Imgur

4

1 に答える 1

5

contentScaleFactor親ビューとそのサブビューのプロパティを再帰的に2.0に設定することで、これを修正することになりました。

UIImageは正しい解像度でレンダリングされていましたrenderInContextが、呼び出されたときにレイヤーがレンダリングされていませんでした。

于 2012-11-05T03:53:59.820 に答える