2014-03-19 61 views
0

我在iOS中使用CorePlot來顯示圖形,並且我能夠顯示y軸自定義標籤但無法看到X軸自定義標籤。iOS核心圖X軸標籤不可見

這裏是代碼我使用用於顯示X軸的自定義標籤..

// 2 - Get axis set 
CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.hostView.hostedGraph.axisSet; 

// 3 - Configure x-axis 
CPTAxis *x = axisSet.xAxis; 
x.titleTextStyle = axisTitleStyle; 
x.titleOffset = 0.0f; 
x.axisLineStyle = axisLineStyle; 
x.labelingPolicy = CPTAxisLabelingPolicyNone; 
x.labelTextStyle = axisTextStyle; 
x.majorTickLineStyle = axisLineStyle; 
x.majorTickLength = 4.0f; 
x.minorTickLength = 0.0f; 
x.tickDirection = CPTSignNegative; 

// Draw labels 
NSArray *xCustomTickLocations = [NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1], [NSDecimalNumber numberWithInt:2],[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:4],[NSDecimalNumber numberWithInt:5],[NSDecimalNumber numberWithInt:6],[NSDecimalNumber numberWithInt:7] ,nil]; 
NSArray *xAxisLabels = [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E",@"F",@"G", nil]; 
NSUInteger labelLocation = 0; 
NSMutableArray *xCustomLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]]; 
for (NSNumber *tickLocation in xCustomTickLocations) { 
    CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle]; 
    newLabel.tickLocation = [tickLocation decimalValue]; 
    [xCustomLabels addObject:newLabel]; 
} 

x.axisLabels = [NSSet setWithArray:xCustomLabels]; 
x.majorTickLocations = [NSSet setWithArray:xCustomTickLocations]; 

請幫助我什麼,我做錯了。刻度線可見,但不是標籤。

回答

0

我發現這個問題,實際上標籤正在繪製,但超出了框架。

所以我只是增加了圖底部填充。