Ios 以编程方式拍摄屏幕截图时,UISegmentedControl中选定段的标题将消失
我将一个Ios 以编程方式拍摄屏幕截图时,UISegmentedControl中选定段的标题将消失,ios,iphone,ios7,uisegmentedcontrol,Ios,Iphone,Ios7,Uisegmentedcontrol,我将一个UISegmentedControl添加到UIToolbar: UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame]; toolbar.barStyle = UIBarStyleBlack; toolbar.translucent = YES; toolbar.barTintColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0];
UISegmentedControl
添加到UIToolbar
:
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
toolbar.barStyle = UIBarStyleBlack;
toolbar.translucent = YES;
toolbar.barTintColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0];
[self.view addSubview:toolbar];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Last week", @"Last month", @"All time"];
[segmentedControl setSelectedSegmentIndex:0];
[toolbar addSubview:segmentedControl];
然后将工具栏添加到视图控制器中。当我拍摄视图控制器的屏幕截图时,奇怪的事情发生了。选定段的标题将消失
正在使用以下方式拍摄屏幕截图:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, [[UIScreen mainScreen] scale]);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
渲染视图:
截图:
从哪里开始查找?我已替换
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
与
现在它的工作原理与预期一致。但我还是不明白为什么会这样
请注意,drawViewHierarchyInRect:AfterScreen更新:
仅适用于iOS 7。我已替换
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
与
现在它的工作原理与预期一致。但我还是不明白为什么会这样
请注意,
drawViewHierarchyInRect:AfterScreen更新:
仅适用于iOS 7。有人有想法吗?drawViewHierarchyInRect:AfterCreenUpdates:是的,我们还有一些其他问题…drawViewHierarchyInRect:AfterCreenUpdates:给您造成了什么问题?iOS8上的drawViewHierarchyInRect有时速度较慢,结果显示为白色图像。我试图替换上面回答中提到的线条,但我仍然面临同样的问题。SegmentedControl的文本在截图中消失了。有人有想法吗?drawViewHierarchyInRect:AfterCreenUpdates:是的,我们还有一些其他问题…drawViewHierarchyInRect:AfterCreenUpdates:给您造成了什么问题?iOS8上的drawViewHierarchyInRect有时速度较慢,结果显示为白色图像。我试图替换上面回答中提到的线条,但我仍然面临同样的问题。SegmentedControl的文本在屏幕截图中消失。