我尝试使用Core-Plot将图像添加到图形中,我希望图像在拖动或收缩时与图形一起移动。我已经尝试过下面的代码,但它没有用。谁能告诉我怎么做?
CALayer *subLayer = [CALayer layer];
subLayer.contents = [UIImage imageNamed:@"image.png"];
subLayer.position = CGPointMake(100, 120);
[_graph addSublayer:subLayer];
答案 0 :(得分:0)
使用绘图空间注释:
CPTBorderedLayer *imageLayer = [[CPTBorderedLayer alloc] initWithFrame:imageFrame];
imageLayer.fill = [CPTFill fillWithImage:[CPTImage imageNamed:@"image.png"]];
NSArray *plotPoint = @[xCoordinate, yCoordinate];
CPTPlotSpaceAnnotation *imageAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:plotSpace
anchorPlotPoint:plotPoint];
imageAnnotation.contentLayer = imageLayer;