我用这段代码画了一个图表:
CAShapeLayer *curentGraph = [CAShapeLayer new];
CGMutablePathRef linePath = CGPathCreateMutable();
curentGraph.lineWidth = 3.0f;
curentGraph.fillColor = [[UIColor clearColor] CGColor];
curentGraph.strokeColor = [colorGraph CGColor];
for (NSValue *value in arrOfPoints) {
CGPoint pt = [value CGPointValue];
CGPathAddLineToPoint(linePath, NULL, pt.x,pt.y);
};
curentGraph.path = linePath;CGPathRelease(linePath);
[self.layer addSublayer:curentGraph];
并且它长这样
但我有一个问题。我需要在图形出现时对其进行动画处理。每个点都应该从位置 y = 0
向上移动到 y = pt.y
的位置。就像此网站上的图表一样。
我如何才能像那样动画显示我的图形呢?