在旋转角度核心图上停止饼图

时间:2011-11-17 08:28:16

标签: iphone ios core-animation core-plot

我通过以下代码旋转饼图

-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point
{
    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];    
    rotation.removedOnCompletion = NO;
    rotation.fromValue = [NSNumber numberWithFloat:M_PI_4]; 
    rotation.toValue   = [NSNumber numberWithFloat:M_PI_4+10]; 
    rotation.duration  = 1.0f;
    rotation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    rotation.delegate = self;
     pieChart.startAngle = M_PI_4+10;
    [pieChart addAnimation:rotation forKey:@"rotation"];
    return YES;
}

但是在旋转饼图回到它的初始位置之后。但我想现在饼图应该处于旋转角度。如何在这里取得成功?

1 个答案:

答案 0 :(得分:0)

this CocoaDev article。它提供了几种可能的解决方案。他们的示例使用position属性,但所讨论的技术适用于任何可动画的属性。