2011-04-23 93 views
0

我正在使用偉大的框架核心圖(在桌面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]; 

感謝您的幫助

回答

1

嗯,我會說,你需要每一個圖形的大小調整的時間來改變註釋的位置。我不認爲Core-Plot可以爲你做到這一點。 檢索註釋並修改其內容層的框架:

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