我有一个菜单,它是一个CALayer,可以在屏幕上滑动到给定点。我想要的效果是,菜单会稍微超出点,然后在点之前一点,然后落在点上。我可以通过应用变换来移动菜单,但我希望让这个弹跳效果发挥作用。我正在查找CAKeyframeAnimation,但我在查找示例/教程时遇到了问题。我看过CA编程指南,但没有真正找到任何东西。任何链接或帮助都会很棒。谢谢。
发布于 2011-04-26 00:26:56
我不久前发布了some code,它做的正是你想要的。基本上,您需要生成自己的CGPathRef,其中包含希望层命中的所有点,并将该路径用于CAKeyframeAnimation的path属性。代码将如下所示:
CGPoint path[3] = {
FTAnimationOutOfViewCenterPoint(enclosingView.bounds, view.frame, view.center, direction),
[self overshootPointFor:view.center withDirection:direction threshold:(overshootThreshold_ * 1.15)],
view.center
};
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathAddLines(thePath, NULL, path, 3);
animation.path = thePath;
CGPathRelease(thePath);整个方法都是here。
https://stackoverflow.com/questions/2634457
复制相似问题