Bri*_*ian 4 iphone animation core-animation calayer uikit
我有一个菜单,它是一个CALayer,可以在屏幕上滑动到给定的点.我想要的效果是菜单会稍微超过点,然后稍微点一点,然后落在点上.我可以通过应用变换来移动菜单,但我希望能够使这种弹跳效果起作用.我正在研究CAKeyframeAnimation,但是我无法找到示例/教程.我看过CA编程指南,但还没有找到任何东西.任何链接或帮助都会很棒.谢谢.
我刚刚发布了一些代码,它可以满足您的需求.基本上,您需要生成自己CGPathRef包含希望图层命中的所有点,并将该路径用于该path属性CAKeyframeAnimation.代码看起来像这样:
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);
Run Code Online (Sandbox Code Playgroud)
整个方法就在这里.
| 归档时间: |
|
| 查看次数: |
6539 次 |
| 最近记录: |