我有一个带有文本、标签和 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 中的第二个参数更改为 false。我仍然看到它充满了。我有什么遗漏吗?
这是图像。