0

次のコードを使用して、編集した UIscrollView を UIImage に保存しようとしています。しかし、ビューに表示されるのは、保存したものではありません。保存された写真の横にある空白の灰色のカラーバーで、どういうわけか相殺されました. UIscrollView がビューのフレームに触れていません。どうやって行くのか誰にも考えがありますか?「theScrollView.layer」を使用してレンダリングする必要がある場合。写真を拡大すると、写真が悪くなります。

CGSize photoSize = theScrollView.bounds.size;
UIGraphicsBeginImageContext(photoSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CALayer *layer = self.view.layer;
[layer renderInContext:context];
UIImage *someImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(someImage,nil, nil, nil);
4

1 に答える 1

0

CGContextRef context = UIGraphicsGetCurrentContext();と置き換えます

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

これは、Retina ディスプレイからキャプチャする場合に役立ちます。

  • uiscrollview のスクリーンショットを撮る必要がある場合は、「self.view.layer」を「yourscrollview.layer」に置き換えてください

幸運を

于 2012-07-29T13:11:10.997 に答える