我试图在核心绘图散点图(如线图)中缩放,以便缩放以查看。 CorePlot使用普通的CALayer来实现它的绘图。CABasicAnimation CorePlot缩放有效
我使用的Core Animation如下来实现这一目标:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"affineTransform"];
animation.duration = 10;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
CGAffineTransform start = CGAffineTransformMakeScale(1, 0.1);
CGAffineTransform end = CGAffineTransformMakeScale(1, 1);
animation.fromValue = [NSValue valueWithCGAffineTransform:start];
animation.toValue = [NSValue valueWithCGAffineTransform:end];
[plot addAnimation:animation forKey:@"animation"];
问题是,这似乎并没有工作。这是我第一次使用核心动画,所以我想我只是做错了什么?
编辑 好吧,所以我发现我使用错误的keypath的问题。
我能得到现在的动画,但它看起来奇怪:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
...
animation.fromValue = [NSNumber numberWithFloat:0.1];
animation.toValue = [NSNumber numberWithFloat:1];
我想要做的是有动画“向上扩展”所以那种绵延的地方。现在它从中心生长出来,这不是我想要的。任何想法如何实现?
当你运行它会发生什么? – Dustin 2012-07-12 14:49:07
什么都没有发生。好像没有动画。我刚刚注意到CALayer上的'affineTransform'成员是一种方法而不是属性,我猜关键路径必须是属性? – Imran 2012-07-12 14:52:02