我无法摆脱CPTGraph边框和CPTPlotAreaFrame之间的差距。
此示例中的深灰色为CPTGraph,浅灰色为CPTPlotAreaFrame。它们都具有{ 150, 150 }
的帧大小。
控制CPTGraph填充的属性是什么? CPTPlotAreaFrame的paddingBottom
和其他人控制CPTPlotAreaFrame的内部填充。
这是代码。
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:hostingView];
CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:NSRectToCGRect(hostingView.bounds)];
graph.fill = [CPTFill fillWithColor:[CPTColor grayColor]];
graph.axisSet = nil;
hostingView.hostedGraph = graph;
// both of these are { 150.0, 150.0 }
NSLog(@"%f %f", graph.frame.size.width, graph.frame.size.height);
NSLog(@"%f %f", graph.plotAreaFrame.frame.size.width, graph.plotAreaFrame.frame.size.height);
graph.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor lightGrayColor]];
graph.plotAreaFrame.masksToBorder = NO;
graph.plotAreaFrame.borderLineStyle = nil;
CPTPieChart *piePlot = [[CPTPieChart alloc] init];
piePlot.dataSource = self.viewModel;
piePlot.pieRadius = MIN( CPTFloat(0.7) * (hostingView.frame.size.height - CPTFloat(2.0) * graph.paddingLeft) / CPTFloat(2.0),
CPTFloat(0.7) * (hostingView.frame.size.width - CPTFloat(2.0) * graph.paddingTop) / CPTFloat(2.0) );
piePlot.identifier = self.title;
piePlot.startAngle = CPTFloat(M_PI_4);
piePlot.sliceDirection = CPTPieDirectionCounterClockwise;
piePlot.labelRotationRelativeToRadius = YES;
piePlot.labelRotation = CPTFloat(-M_PI_2);
piePlot.labelOffset = -50.0;
piePlot.delegate = self;
[graph addPlot:piePlot];
答案 0 :(得分:1)
在graph
本身设置填充。 CPTGraph
以每边20个像素的填充开始。
graph.paddingLeft = 0.0;
graph.paddingTop = 0.0;
graph.paddingRight = 0.0;
graph.paddingBottom = 0.0;