Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何向core plot graph添加图层_Objective C_Core Plot - Fatal编程技术网

Objective c 如何向core plot graph添加图层

Objective c 如何向core plot graph添加图层,objective-c,core-plot,Objective C,Core Plot,使用core plot CPTXYGraph,我想在轴的后面但在绘图线的顶部添加一个背景。就我的研究而言,唯一的方法是添加一个定制的CPTLayer,并尝试将其正确定位。我的问题是,尽管我设置了帧,CPTLayer始终会增长到图形的完整大小。我怎样才能解决这个问题?谢谢 CPTLayer *layer = [CPTLayer layer]; layer.frame = CGRectMake(0, 0, 200, 200); layer.backgroundColor = [[UIColor co

使用core plot CPTXYGraph,我想在轴的后面但在绘图线的顶部添加一个背景。就我的研究而言,唯一的方法是添加一个定制的CPTLayer,并尝试将其正确定位。我的问题是,尽管我设置了帧,CPTLayer始终会增长到图形的完整大小。我怎样才能解决这个问题?谢谢

CPTLayer *layer = [CPTLayer layer];
layer.frame = CGRectMake(0, 0, 200, 200);
layer.backgroundColor = [[UIColor colorWithRed:0.1 green:0.2 blue:0.3 alpha:0.6] CGColor];
[self.graph addSublayer:layer];

使您的视图成为CPTGraphHostingView的子类

然后在实施中,

CPTXYGraph      *graph;

hostingView = (CPTGraphHostingView *)hostingView;
hostingView.hostedGraph = graph;

CPTLayer *subLayer = [[CPTLayer alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
subLayer.backgroundColor = [UIColor redColor].CGColor;
[self.hostingView.layer addSublayer:subLayer];

使您的视图成为CPTGraphHostingView的子类

然后在实施中,

CPTXYGraph      *graph;

hostingView = (CPTGraphHostingView *)hostingView;
hostingView.hostedGraph = graph;

CPTLayer *subLayer = [[CPTLayer alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
subLayer.backgroundColor = [UIColor redColor].CGColor;
[self.hostingView.layer addSublayer:subLayer];

可以将图层作为“注释”添加到图形中。创建图层注释,将您的
CPTLayer
设置为内容图层,并将注释添加到图形中。

您可以将图层作为“注释”添加到图形中。创建一个图层注释,将您的
CPTLayer
设置为内容图层,并将注释添加到图表中。

查看此注释,可以清楚地了解核心绘图。

查看此注释,可以清楚地了解核心绘图。

谢谢@iUser,这很有效!我不知道我怎么会知道?因为我在文档中找不到答案。而且原点似乎从左下角开始,而不是左上角。是这样吗?谢谢@iUser,这很有效!我不知道我怎么会知道?因为我在文档中找不到答案。而且原点似乎从左下角开始,而不是左上角。是这样吗?