How do I animate the appearance of a bar chart in Core Plot?

前端 未结 5 2244
一生所求
一生所求 2021-02-10 06:49

When first displaying a bar chart using Core Plot, I\'d like the bars to grow upward until they reach their correct heights.

How would you create such an animation usi

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-10 06:55

    Add animation for your CPTBarPlot as follows:

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
    [animation setDuration:1];
    CATransform3D transform = CATransform3DMakeScale(1, 0.0001, 1);
    // offsetY=[PlotDisplayAreaUnderXAxisHeight]-[PlotDisplayAreaHeight]/2
    transform = CATransform3DConcat(transform, CATransform3DMakeTranslation(0, offsetY, 0));
    animation.fromValue = [NSValue valueWithCATransform3D:transform];
    animation.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
    [barPlot addAnimation:animation forKey:@"barGrowth"];
    

提交回复
热议问题