3

次のコードがあります。

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
    UIGraphicsBeginImageContextWithOptions(mainView.bounds.size, NO, [UIScreen mainScreen].scale);
}
else {
    UIGraphicsBeginImageContext(mainView.bounds.size);
}

[mainView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *saveImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

mainView には、このメソッドを使用すると saveImage に表示されないマスクされたサブビューがあります。ただし、そのようなアクティビティをキャプチャする iOS 4 より前の UIGetScreenImage メソッドがあったことは理解しています。私の質問は、iOS 6 で CALayer のアクティビティをキャプチャする最良の方法は何ですか? UIGetScreenImage はまだ非公開ですか?

4

2 に答える 2

0

レイヤーの状態が含まれるため、代わりにプレゼンテーションレイヤーを取得してみてください。

[mainView.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];

https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instm/CALayer/presentationLayer

于 2013-07-24T13:38:36.510 に答える