テキスト、ラベル、Uisegmented ボタンのある画面があります。画面全体のスナップショットを撮り、画像として保存したい。
これがコードです。
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*theImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData*theImageData=UIImageJPEGRepresentation(theImage, 1.0 ); //you can use PNG too
[theImageData writeToFile:@"example.jpeg" atomically:YES];
ただし、Uisegmented ボタンで選択されたオプションは不透明に塗りつぶされて表示されます。UIGraphicsBeginImageContextWithOptions の 2 番目のパラメーターを false に変更しました。それでも私はそれが満たされているのを見ます。不足しているものはありますか?
これが画像です。