2012-03-19 15 views
3

コアプロットを使用して生成する円グラフにプレーンブラックの背景を使用したいと思います。私はうまくチャートのレンダリングを持っていますが、タイトルは黒の背景に見えにくいデフォルトのblackColorにあります。私はそれが表示されていることを知っているので、私はテーマを変更するときに私はそれを黒で見ることができます。誰も私がデータラベルで行ったようにテキストの色を変更する方法を教えてもらえますか?ここでコアプロット円グラフのタイトルの外観を変更します

は...提供するどのような援助/アドバイス/リンクを事前に

graph = [[CPTXYGraph alloc] initWithFrame:self.view.bounds]; 
    CPTGraphHostingView *hostingView = (CPTGraphHostingView*)self.view; 
    hostingView.hostedGraph = graph; 

    CPTPieChart *pieChart = [[CPTPieChart alloc] init]; 
    pieChart.dataSource = self; 
    pieChart.pieRadius = 80.0; 
    pieChart.identifier = @"PieChart1"; 
    pieChart.startAngle = M_PI_4; 
    pieChart.sliceDirection = CPTPieDirectionCounterClockwise; 

    [graph addPlot:pieChart]; 
    graph.title = @"Proportion of Sessions per Sport"; 

} 

-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index { 
    static CPTMutableTextStyle *whiteText = nil; 
    if (!whiteText) { 
     whiteText = [[CPTMutableTextStyle alloc] init]; 
     whiteText.color = [CPTColor whiteColor]; 
    } 

    CPTLayer *layer = [[CPTLayer alloc] initWithFrame:CGRectMake(50, 50, 100, 20)]; 
    CPTTextLayer *newLayer = nil; 
    newLayer = [[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%@", [pieLabels objectAtIndex:index]] style:whiteText]; 
    [layer addSublayer:newLayer]; 
    return newLayer; 
} 

-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot { 
    return [self.pieData count]; 
} 

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { 
    return [self.pieData objectAtIndex:index]; 
} 

-(NSString *)legendTitleForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index { 
    return [NSString stringWithFormat:@"Pie Slice %u", index]; 
} 

感謝私のコードの抜粋です...

答えて

5

私はそれが私を見つめていた答えを見つけました

CPTMutableTextStyle *whiteText = [CPTMutableTextStyle textStyle]; 
    whiteText.color = [CPTColor whiteColor]; 
    graph.titleTextStyle = whiteText; 
    graph.title = @"Your Title Here..."; 
:ここにこの質問時につまずく誰のために

がその答えです...コアプロットサンプルコードで全体の時間に直面しています

関連する問題