Cocoa 核心图:注释位置

Cocoa 核心图:注释位置,cocoa,core-plot,Cocoa,Core Plot,我正在使用great framework core plot(在桌面OSX中)绘制图形。 据我所知,我已经成功地正确地绘制了表格,但是我在注释方面遇到了问题 我需要在图形的顶部中心位置(而不是绘图区域)添加图像注释。我已经设法在启动时将注释放置在那里,但每当我调整窗口大小时,图形都会调整大小,但注释会保持初始位置,不再移动到图形的上止点位置。 我正在做这样的事情: // This layer will be the annotation Content CPBorderedLayer

我正在使用great framework core plot(在桌面OSX中)绘制图形。 据我所知,我已经成功地正确地绘制了表格,但是我在注释方面遇到了问题

我需要在图形的顶部中心位置(而不是绘图区域)添加图像注释。我已经设法在启动时将注释放置在那里,但每当我调整窗口大小时,图形都会调整大小,但注释会保持初始位置,不再移动到图形的上止点位置。 我正在做这样的事情:

// This layer will be the annotation Content
      CPBorderedLayer * logoLayer = [[(CPBorderedLayer *)[CPBorderedLayer alloc] 
                        initWithFrame:   CGRectMake(xMiddle, yTop, logoWidth,
     logoHeight)      ] autorelease];

            CPFill *fillImage = [CPFill fillWithImage:imgLogo];
            logoLayer.fill = fillImage;

// Create a new annotation
            CPAnnotation *annot = [[CPAnnotation alloc]init];
            annot.contentLayer = logoLayer;
            annot.displacement = CGPointMake(50,50);

   // graph is my CPXYGraph instance
   // Add annotation to the graph     
[graph addAnnotation:annot];

感谢您的帮助

嗯,我想说的是,每次调整图形的大小时,您都需要更改注释的位置。我不认为核心情节能为你做到这一点。 检索注释,并修改其内容层的框架:

CPAnnotation *annot = [self.graph.annotations objectAtIndex:0];
annot.contentLayer.frame = CGRectMake(newXCoord, newYCoord, logoWidth, logoHeight);