【发布时间】:2014-05-22 10:01:08
【问题描述】:
在我的代码中,使用 CPTPlotSpaceAnotaions 代替数据标签的代码图像在条形图的每个条形图的中心显示。图像放置在中心并且工作正常,但如果图像被放大,它会被拉伸到条形之外。我需要它来切断条宽。
图像是使用绘制的,
CPTBorderedLayer *borderedLayerObject =[[CPTBorderedLayer alloc] initWithFrame:CGRectMake(0, 0, 52, 52)];
borderedLayerObject.fill = [CPTFill fillWithImage:cptimage];
NSArray *anchorPoint = [NSArray arrayWithObjects:xPosition, yPosition, nil];
CPTPlotSpaceAnnotation *imageAnnotation = [[CPTPlotSpaceAnnotation alloc]initWithPlotSpace:graph.defaultPlotSpace anchorPlotPoint:anchorPoint];
imageAnnotation.contentLayer = borderedLayerObject;
[graph.plotAreaFrame addAnnotation:imageAnnotation];
return imageAnnotation;
并将这个borderedLayerObject设置为CPTPlotSpaceAnnotation的contentLayer,返回CPTPlotSpaceAnnotation对象...
我绘制的图像采用borderedLayerObject 的帧大小并将其放置在条形图中的条上,所以我无法理解如何裁剪我绘制的图像......
CPTPlotSpaceAnnotation 用于因为我需要在条形图的中心显示图像,使用锚点我已经给出了图像必须显示在条形图的条形图中的 x 和 y 位置。请帮我解决...
【问题讨论】: