0

我已经设置了一个以时间为 x 轴的散点图。我在中午的时候在背景中画了一个小太阳图像:

CGRect imageRect = CGRectMake(0, 0 , 50, 50);
CPTBorderedLayer * imageLayer = [[CPTBorderedLayer alloc] initWithFrame:imageRect];
imageLayer.fill = [CPTFill fillWithImage:[CPTImage imageWithCGImage:[[UIImage imageNamed:@"SunIcon.png"] CGImage]]];
NSArray *anchorPoint = [NSArray arrayWithObjects:
                        [NSNumber numberWithInt:12*60*60], [NSNumber numberWithInt:100],
                        nil];
CPTPlotSpaceAnnotation *imageAnnotation1 = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:(CPTXYPlotSpace *)graph.defaultPlotSpace anchorPlotPoint:anchorPoint];
imageAnnotation.contentLayer = imageLayer;
[graph addAnnotation:imageAnnotation];
[graph addSublayer:imageLayer];

问题是太阳现在隐藏了我的阴谋。如何将图像发送到所有情节后面的背景?

编辑:相反的情况是我的右对齐 y 轴被图隐藏了。我可以把这层放在前面吗?

4

1 回答 1

0

将注释添加到绘图区域,然后将图像层移动到子层顺序的前面。

[graph.plotAreaFrame.plotArea addAnnotation:imageAnnotation];
[imageLayer removeFromSuperlayer];
[graph.plotAreaFrame.plotArea insertSublayer:imageLayer atIndex:0];
于 2012-05-22T01:32:44.737 回答