0

テキスト、ラベル、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 に変更しました。それでも私はそれが満たされているのを見ます。不足しているものはありますか?

これが画像です。ここに画像の説明を入力

4

1 に答える 1

0

UISegmentedControl問題はクラスに固有のようです。なぜそれが起こっているのかわかりませんが、以下のようなものがうまくいくはずです。

[segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor orangeColor]} forState:UIControlStateNormal];

この情報は、問題をさらに調査するのに役立つ場合があります。

于 2014-03-27T16:01:48.350 に答える