How to set the color of a UILabel object same as the pie chart slice color when sliceWasSelectedAtRecordIndex: method is called in core plot? I am filling slice with gradient color with this method.
-(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];
}
}
Make the
CPTGradientusingCPTColorobjects, notUIColors.You can set the
backgroundColorof aUILabelto a singleUIColor. I’m not sure how you’d do it with a gradient without making a custom subclass that draws the background gradient.