尝试使用CorePlot的CPTPieChart并将其打印到打印机
CPTGraphHostingView *view = [[CPTGraphHostingView alloc] initWithFrame:CGRectMake(10, 10, 600, 600)];
CPTXYGraph *printgraph = [[CPTXYGraph alloc] initWithFrame:CGRectMake(10, 10, 600, 600)];
view.printRect = CGRectMake(10, 10, 600, 600);
view.hostedGraph = printgraph;
printgraph.axisSet = nil;
printgraph.delegate = self;
printgraph.title = @"Client Statistics";
printgraph.plotAreaFrame.masksToBorder = NO;
// Prepare a radial overlay gradient for shading/gloss
CPTGradient *overlayGradient = [[CPTGradient alloc] init];
overlayGradient.gradientType = CPTGradientTypeRadial;
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.0] atPosition:0.0];
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.2] atPosition:0.9];
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.5] atPosition:1.0];
CPTPieChart *pie = [[CPTPieChart alloc] init];
pie.dataSource = self;
pie.delegate = self;
pie.pieRadius = 190;
pie.startAngle = M_PI_4;
pie.labelRotation = 0;
pie.labelOffset = -30.0;
pie.sliceDirection = CPTPieDirectionClockwise;
pie.overlayFill = [CPTFill fillWithGradient:overlayGradient];
pie.labelRotationRelativeToRadius = NO;
[printgraph addPlot:pie];
[printgraph reloadData];
.... ....
printOp = [NSPrintOperation printOperationWithView:view printInfo:printInfo];
[printOp runOperation];
标题显示在“打印预览”窗口中,但实际饼图为空白 如果我将视图添加到self.window.contentView,我可以看到饼图,以便正确构建和显示,但不打印?
任何想法 提前致谢