How do remove the border around a core-plot graph

后端 未结 7 2029
北荒
北荒 2021-01-31 18:42

I am trying to remove the border around a core plot graph on the iPhone - but seem to be struggling on what should be simple in my mind.

Pointers please!

7条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 18:59

    If, like me, you are looking to not just remove the border line, but to make a plot that takes up the entire hosting view, the answer from Thomas Johannesmeyer got me on the right track.

    Here's what I did:

    CPTGraphHostingView* hostingView = [[CPTGraphHostingView alloc] initWithFrame: frame];
    CGRect bounds = hostingView.bounds;
    
    CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:bounds];
    hostingView.hostedGraph     = graph;
    
    graph.paddingTop    = CPTFloat(0.0);
    graph.paddingRight  = CPTFloat(0.0);
    graph.paddingBottom = CPTFloat(0.0);
    graph.paddingLeft   = CPTFloat(0.0);
    
    graph.plotAreaFrame.paddingTop    = CPTFloat(0.0);
    graph.plotAreaFrame.paddingRight  = CPTFloat(0.0);
    graph.plotAreaFrame.paddingBottom = CPTFloat(0.0);
    graph.plotAreaFrame.paddingLeft   = CPTFloat(0.0);
    graph.plotAreaFrame.masksToBorder = NO;
    
    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
    CPTXYAxis *x          = axisSet.xAxis;
    x.labelingPolicy      = CPTAxisLabelingPolicyNone;
    x.title = nil;
    CPTXYAxis *y          = axisSet.yAxis;
    y.labelingPolicy      = CPTAxisLabelingPolicyNone;
    y.title = nil;
    

提交回复
热议问题