2012-08-22 61 views
1

如何將X軸標籤的文本右移(水平)? 我希望能夠在兩個x-ticks之間顯示一個字符串(例如| Jan | Feb | ...),而不是跨越x-tick。如何將Core-Plot X標籤移動到滴答聲之間?

我試過如下:

newLabel = [[CPTAxisLabel alloc] initWithText:item.month textStyle:x.labelTextStyle]; 
newLabel.tickLocation = [[NSDecimalNumber numberWithInt:index] decimalValue]; 

CGPoint myPoint = newLabel.contentLayer.position; 
CGFloat x = myPoint.x; 
CGPoint yourPoint = myPoint; 
yourPoint.x += 16.0; 

[newLabel positionBetweenViewPoint:myPoint andViewPoint:yourPoint forCoordinate:CPTCoordinateX inDirection:CPTSignPositive]; 

...但我得到了一個SIGABRT錯誤(崩潰)。
一個例子勝過千言萬語。

問候, 裏克

回答

0

沒有一個簡單的方法來做到這一點現在。您需要使用自定義標籤。將軸標籤策略設置爲CPTAxisLabelingPolicyNone並設置所需的勾號位置和標籤。請參閱Plot Gallery應用程序中的labeling policy demo以獲取一些示例代碼。

相關問題