私のコードでわかるように、私はスクリーンショットを撮ってフォトアルバムに保存します。 特定のエリアのスクリーンショットをプログラムで取得する
//for retina displays
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(self.view.bounds.size);
}
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
は、初めに私の代わりに
self.view.bounds.size
の
webview.size
を使用してビューが
0/0
に位置していたので、それが正常に働いていました。しかし、今私はWebViewを中心にしていますが、画像は指定サイズの
0/0
から始まります。
スクリーンショットが指定サイズの別のlocation
(たとえば300/150
)で始まるように設定するにはどうすればよいですか?
UIWebView
の写真を撮る別の方法はありますか?
これはデスクトップOSXまたはiphoneだけで動作しますか? – Noitidart