随着时间的推移,我正在使用核心绘图来绘制一个图形,目前将x轴的labelingPolicy设置为CPTAxisLabelingPolicyAutomatic。但是,我想用右下角来画一幅图像。所以我需要阻止地皮在那个地方画标签。我考虑过使用labelExclusionRanges,但这需要从物理大小到时间值范围的映射。有更简单的方法来达到我的目标吗?
试图将Eric的答案转换成代码可以得到一个图像,但它现在放在x轴旁边,而我真的希望它位于x轴标签的右边。它也部分偏离了图表的主视图..。
UPDATE:需要将layer.frame设置为实际查看图像。
- (void)annotateXAxisOfGraph:(CPTGraph *)graph withImage:(CPTImage *)image
{
CPTBorderedLayer *layer = [[[CPTBorderedLayer alloc] init] autorelease];
layer.fill = [CPTFill fillWithImage:image];
layer.frame = CGRectMake(0.0f, 0.0f, 40.0f, 40.0f);
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTLayerAnnotation *layerAnnotation = [[[CPTLayerAnnotation alloc] initWithAnchorLayer:axisSet.xAxis] autorelease];
layerAnnotation.contentLayer = layer;
layerAnnotation.rectAnchor = CPTRectAnchorBottomRight;
[graph addAnnotation:layerAnnotation];
}发布于 2013-04-16 23:18:12
制作一个CPTBorderedLayer并使用您的图像制作它的fill。将此层用作图层注释的内容层,并将注释附加到所需位置的图形上。
https://stackoverflow.com/questions/16033583
复制相似问题