如何实现 UIViewAnimationOptionBeginFromCurrentState
我有一段音频&相关的游戏和停止按钮,当按下播放按钮时,我使用光标动画来表示给定时刻我们在音频样本中的哪个点。每当按下停止按钮时,我希望光标返回到其初始坐标。我相信 UIViewAnimationOptionBeginFromCurrentState 可能是执行此操作的方法?我的初始动画代码如下,有人对如何使用 UIViewAnimationOptionBeginFromCurrentState 将光标发送回其原始坐标有任何提示吗?
感谢您提前提供任何帮助:)
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:2.0f];
yellowBar.frame = CGRectMake(310, 20, 5, 100);
[UIView commitAnimations];
I have a piece of audio & associated Play & Stop buttons, when the Play button is pressed I use an animation of a curser to denote at which point in the audio sample we are, at a given moment. Whenever the stop button is pressed I want my curser to return to its initial coordinates. I believe UIViewAnimationOptionBeginFromCurrentState might be the way to do this? My code for the initial animation is below, anyone have any tips on how to use UIViewAnimationOptionBeginFromCurrentState in order to send the cursor back to its original coordinates?
Thanks for any help in advance :)
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:2.0f];
yellowBar.frame = CGRectMake(310, 20, 5, 100);
[UIView commitAnimations];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您仍在使用 beginAnimations/commitAnimations,请使用
setAnimationBeginsFromCurrentState:
。否则,您可以将 UIViewAnimationOptionBeginFromCurrentState 传递给 animateWithDuration:delay:options:animations:completion: 作为 options 参数。If you are still using beginAnimations/commitAnimations, use
setAnimationBeginsFromCurrentState:
. Otherwise, you can pass UIViewAnimationOptionBeginFromCurrentState toanimateWithDuration:delay:options:animations:completion:
for the options parameter.布莱恩是对的,你有两种选择:
或者
Brian is right, you have got two alternatives:
Or
AFAIK 您只能将该选项与基于块的动画一起使用(无论如何都鼓励您使用)。您可以使用
animateWithDuration:delay:options:animations:completion:
方法,所述方法此处。AFAIK you can only use that option with block-based animations (which you are encouraged to use anyway). You'd use the
animateWithDuration:delay:options:animations:completion:
method, described here.