首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Core-Plot:注释位置

Core-Plot:注释位置
EN

Stack Overflow用户
提问于 2011-04-23 08:54:04
回答 1查看 1.7K关注 0票数 0

我正在使用一个很棒的框架core-plot (在桌面OSX中)在一个图表中工作。到目前为止,我已经设法正确地绘制了表格,但我在注释方面遇到了问题。

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

代码语言:javascript
运行
复制
// 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];

谢谢你的帮忙

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-08 17:25:53

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

代码语言:javascript
运行
复制
CPAnnotation *annot = [self.graph.annotations objectAtIndex:0];
annot.contentLayer.frame = CGRectMake(newXCoord, newYCoord, logoWidth, logoHeight);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5761374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档