我使用Core Plot在我的iPad应用程序中有一个分散图表,一切运行良好。我想要做的是为线条绘制设置动画,使其看起来像是在用户面前绘制图形上的每个点。我不打算淡化这条线,因为我已经开始工作了。
我在下面看到的问题非常相似,但我并不完全理解答案。 Core-Plot - animating a CPScatterPlot
请记住,我是Core Plot的新手并且只使用它一天左右。
由于
答案 0 :(得分:3)
self.plot.anchorPoint = CGPointMake(0.0, 0.0); // Moved anchor point,
CABasicAnimation *scaling = [CABasicAnimation
animationWithKeyPath:@"transform.scale.y"]; // s
scaling.fromValue = [NSNumber numberWithFloat:0.0];
scaling.toValue = [NSNumber numberWithFloat:1.0];
scaling.duration = 0.1f; // Duration
scaling.removedOnCompletion = NO;
scaling.fillMode = kCAFillModeForwards;
[self.plot addAnimation:scaling forKey:@"scaling"];
答案 1 :(得分:1)
查看Core Plot附带的Plot Gallery示例应用程序中的“实时演示”图。它使用计时器一次一个地向散点图添加点。可以找到代码here。
-newData:
方法为绘图添加一个点并更新绘图范围,以便新点可见。对-insertDataAtIndex:numberOfRecords:
的调用会导致绘图检索新数据点并自动重绘。