2011-10-24 52 views
0

是否可以将UIImageView添加到CPTBarPlot图层(从Core Plot框架中)?我曾尝试以下,但它只有在图形角创建图像,我希望它是上吧:如何将图像添加到Core Plot CPTBarPlot图层?

NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"wrong.png"];   
     UIImage *image = [[UIImage alloc] initWithContentsOfFile:bundlePath]; 
     UIImageView *incorrect = [[UIImageView alloc] initWithFrame:CGRectMake(plot.bounds.origin.x,plot.bounds.origin.y,14,14)]; 
     [incorrect setImage:image]; 
     [plot addSublayer:incorrect.layer]; 

     [image release]; 
     [incorrect release]; 

回答

1

我想你可以通过创建具有图像的CPTFill做到这一点,使用条形图的代表/数据源返回条形图的填充。

如果您不希望图像实际位于栏中,而是位于其旁边或顶部,则最好创建一个CPTPlotSpaceAnnotation,然后将其附加到绘图区域。

+0

谢谢!指出我的方向正确 – Skeep