如何使用iphone sdk中的核心图库libraru删除添加到饼图的标签的阴影

时间:2011-10-22 14:03:33

标签: objective-c ios4 core-plot

我为饼图添加了阴影,但我也为标签数据添加了阴影。我想删除那个阴影。请帮我。 提前谢谢。

            piePlot.dataSource = self;
    piePlot.pieRadius = 65.0;
    piePlot.pieInnerRadius = 35.0;  
    piePlot.shadowColor = [[UIColor blackColor]CGColor];
    piePlot.shadowRadius = 3.0;
    piePlot.shadowOffset = CGSizeMake(8,-3);
    piePlot.shadowOpacity = 1.0;
    piePlot.identifier = @"Current Year Credits By Type";
    piePlot.startAngle = M_PI_4;
    piePlot.sliceDirection = CPTPieDirectionClockwise;
    piePlot.borderLineStyle = [CPTLineStyle lineStyle];
    piePlot.sliceLabelOffset = 10.0;

- (CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index {

CPTTextLayer *newLayer = nil;

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText )
{
    whiteText = [[CPTMutableTextStyle alloc] init];
    whiteText.color = [CPTColor blackColor];
}

if ( [plot isKindOfClass:[CPTPieChart class]] ) 
{
    NSString *str = [NSString stringWithFormat:@"%@",[pieChartData1 objectAtIndex:index]];

    newLayer = [[[CPTTextLayer alloc] initWithText:str style:whiteText] autorelease];

}

return newLayer;

}

1 个答案:

答案 0 :(得分:1)

使用Core Plot的CPTShadow类而不是CALayer阴影属性。

CPTMutableShadow *blackShadow = [CPTMutableShadow shadow];
blackShadow.shadowOffset = CGSizeMake(8,-3);
blackShadow.shadowColor = [CPTColor blackColor];

piePlot.shadow = blackShadow;