Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
556 views
in Technique[技术] by (71.8m points)

iphone - How to animate the pie charts developed using core-plot library?

In the iPhone application Roambi, the pie chart shown can be animated to rotate with the user as if rotating a disc. We can hold and do lot of stuff with that.

Someone mentioned that the Roambi app was developed using core-plot library:

What library use Roambi app iPhone to draw chart?

How can I manipulate a pie chart developed using Core plot?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...