2
如何在覈心圖中調用sliceWasSelectedAtRecordIndex:
方法時如何設置與餅圖切片顏色相同的對象UILabel
的顏色?我用這種方法用漸變色填充切片。Objective C核心圖:餅圖傳說
-(CPTFill *)sliceFillForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index
{
sectorColour=[[[CPTFill alloc]init]autorelease];//creating a sector color object
if (index == 0) {
//creating cptcolor
CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.0
green:0.7
blue:1.0
alpha:1.0];
CPTColor *areaColor2 = [CPTColor colorWithComponentRed:0.0
green:0.1
blue:0.2
alpha:1.0];
UIColor *color1=[UIColor colorWithRed:0.0 green:0.7 blue:1.0 alpha:1.0];
UIColor *color2=[UIColor colorWithRed:0.0 green:0.1 blue:0.2 alpha:1.0];
//filling with gradient color with CPTColor
CPTGradient *areaGradientUI = [CPTGradient gradientWithBeginningColor:(CPTColor *)color1 endingColor:(CPTColor *)color2];
sectorColour=[CPTFill fillWithGradient:areaGradientUI];
}
}