我正在尝试缩放核心图散点图(如折线图),以便它可以缩放以查看。CorePlot 使用普通的 CALayer 来实现它的绘图。
我使用如下核心动画来实现这一点:
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"];
问题是这似乎不起作用。这是我第一次使用核心动画,所以我想我只是做错了什么?
编辑 好,所以我发现我使用了错误的密钥路径的问题。
我现在可以让它动画,但它看起来很奇怪:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
...
animation.fromValue = [NSNumber numberWithFloat:0.1];
animation.toValue = [NSNumber numberWithFloat:1];
我想做的是让动画“向上缩放”,这样它就可以伸展到位。现在它有点从中心长出来,这不是我想要的。知道如何实现吗?