A quick look at the Core Plot source code reveals that CPPieChart
's inheritance looks like this:
CPPieChart : CPPlot : CPAnnotationHostLayer : CPLayer : CALayer
So you can see that in the end, CPPieChart
is just a heavily subclassed CALayer
. I might be entirely incorrect here, but there's nothing that indicates that this can't be animated like any other CALayer
. Try the following code to rotate the layer by 360 degrees:
CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D transform = CATransform3DMakeRotation(DegreesToRadians(360), 0, 0, 1);
rotation.toValue = [NSValue valueWithCATransform3D:transform];
rotation.duration = 10.0f;
[pieChart addAnimation:rotation forKey:@"rotation"];
If you can get this working then its just a matter of reading the values from the accelerometer and converting them to rotation angles.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…