核心 - 情节:注释位置
问题描述:
我正在使用伟大的框架核心图(在桌面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];
感谢您的帮助
答
嗯,我会说,你需要每一个图形的大小调整的时间来改变注释的位置。我不认为Core-Plot可以为你做到这一点。 检索注释并修改其内容层的框架:
CPAnnotation *annot = [self.graph.annotations objectAtIndex:0];
annot.contentLayer.frame = CGRectMake(newXCoord, newYCoord, logoWidth, logoHeight);