【发布时间】:2014-05-14 13:14:36
【问题描述】:
我有一个CAKeyframeAnimation,我想在我从屏幕左侧滑动手指时继续播放它(iOS 7 中的向后滑动手势)。目前,当我向后滑动时,它会跳到它的 startPosition 并保持静止,并且看起来相当草率。
ViewController 是我从另一个ViewController 推送的detailViewController。当然,我不希望在后台关闭detailViewController 后播放动画。就在被解雇的时候。
这是我的动画:
CGPoint startPoint = (CGPoint){160.f, 160.f};
CGPoint endPoint = (CGPoint){160.f, 15.f};
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 20.f;
animation.path = thePath;
animation.autoreverses = YES;
animation.repeatCount = INFINITY;
[self.myButton.layer addAnimation:animation forKey:@"position"];
任何帮助将不胜感激,谢谢!
使用模式详细信息进行编辑:我在 TableView 顶部有一个 UIView(顺便说一下,我没有使用 Storyboard)。在这个 UIView 里面是一个可以上下移动的 UIButton。因此,UIView 充当了查看 UIButton 上下移动的一种“窗口”。当我向后滑动时,并且 detailViewController 向右移动时,我希望 UIButton 继续按原样制作动画。 (在 tableView 之上,我的意思是它位于 tableView 之上。它不是分层的)。
【问题讨论】:
-
你能描述一下你想要达到的效果吗?如果您只是想让 UIView 在屏幕上滑动,那么您这样做是最困难的。
-
我在 TableView 之上有一个 UIView(顺便说一下,我没有使用 Storyboards)。在这个 UIView 里面是一个可以上下移动的 UIButton。因此,UIView 充当了查看 UIButton 上下移动的一种“窗口”。当我向后滑动,并且 detailViewController 向右移动时,我希望 UIButton 继续保持动画效果。
-
(在tableView之上,我的意思是它位于tableView之上。它不是分层的)。
-
您是否正在寻找“动画”以与关闭过渡同步移动和/或过渡是否具有交互性?
-
它与解雇完全不同步——事实上,在大多数 iOS 7 应用程序中,“解雇”只是一个常规的向后滑动手势。我只想让动画继续播放,直到 detailViewController 完全看不见 :) 希望这不会太难做?
标签: ios caanimation