Kin*_*ven 5 iphone core-plot ios
当使用Core Plot首次显示条形图时,我希望条形图向上生长,直到它们达到正确的高度.
你会如何使用这个框架创建这样的动画?
小智 11
这就是我做的:
在我的viewDidLoad控制器的方法中,我创建了CPTXYGraph:
graph = [[CPTXYGraph alloc] initWithFrame:self.view.bounds];
Run Code Online (Sandbox Code Playgroud)我在空图中添加了动画:
CAKeyframeAnimation *scale = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
Run Code Online (Sandbox Code Playgroud)然后在animationDidStop委托的方法中,我将绘图数据和动画添加到图形中:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
[anim setDuration:2.0f];
anim.toValue = [NSNumber numberWithFloat:1.0f];
anim.fromValue = [NSNumber numberWithFloat:0.0f];
anim.removedOnCompletion = NO;
anim.delegate = self;
anim.fillMode = kCAFillModeForwards;
gPlot.anchorPoint = CGPointMake(0.0, 0.0);
[gPlot addAnimation:anim forKey:@"grow"];
[graph addPlot:gPlot ];// IMPORTANT here I added the plot data to the graph :) .
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
5462 次 |
| 最近记录: |