【发布时间】:2012-07-12 14:44:49
【问题描述】:
我正在尝试在核心图散点图(如折线图)中进行缩放,以便将其缩放以查看。 CorePlot 使用普通的 CALayer 来实现它的绘图。
我使用Core动画如下实现:
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];
我想做的是让动画“向上缩放”,这样它就可以伸展到位。现在它有点从中心长出来,这不是我想要的。知道如何实现吗?
【问题讨论】:
-
运行时会发生什么?
-
什么也没发生。好像没有动画一样。我刚刚注意到 CALayer 上的 'affineTransform' 成员是方法而不是属性,我猜关键路径需要是属性?
标签: iphone objective-c ios core-animation core-plot