iphone - UIViewAnimationOptionRepeat在两个动画之间暂停

标签 iphone ios animation

我想要实现连续脉冲效果,就像在ECG(心跳监视器)中一样。目前,我正在使用两个动画块。

[UIView animateWithDuration: 2.0f delay: 0.0f options: UIViewAnimationOptionRepeat  | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionTransitionNone | UIViewAnimationOptionOverrideInheritedDuration
                 animations:^{ [image1 setFrame:CGRectMake(0,200,320,70)];}
                 completion:^(BOOL finished){[image1 setFrame:CGRectMake(-320,200,320,70)];}];

[UIView animateWithDuration:2.0f delay:0.0f options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionTransitionNone | UIViewAnimationOptionOverrideInheritedDuration
                 animations:^{ [image2 setFrame:CGRectMake(320,200,320,70)];}
                 completion:^(BOOL finished){[image2 setFrame:CGRectMake(0,200,320,70)];}];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];

[UIView commitAnimations];

此动画在完成后会重复执行,但是需要稍稍停顿才能再次凝视。.我想消除之间的停顿,以实现连续而流畅的动画。

任何帮助将不胜感激。

提前致谢..

就是这样,您知道我也尝试过UIViewAnimationCurveEaseInOut ..但它仍然暂停。

最佳答案

最终我发现了...我使用下面的代码来实现流畅且不间断的动画。

[UIView animateWithDuration:2.5f delay:0.0f options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveLinear
                 animations:^{ [image1 setFrame:CGRectMake(0,200,320,70)];}
                 completion:^(BOOL finished){}];

[UIView animateWithDuration:2.5f delay:0.0f options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveLinear
                 animations:^{ [image2 setFrame:CGRectMake(320,200,320,70)];}
                 completion:^(BOOL finished){}];

重要的更改是我不得不将 UIViewAnimationCurveLinear 替换为 UIViewAnimationOptionCurveLinear

关于iphone - UIViewAnimationOptionRepeat在两个动画之间暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14705450/

相关文章:

ios - 'NSInvalidUnarchiveOperationException',原因 : 'Could not instantiate class named UIStoryboardPresentationSegueTemplate'

iphone - xcode4中CFNetwork.framework被误删除

iphone - viewDidLoad 在启动时在 rootViewController 上被调用两次

iphone - 第三方 iOS 库中的私有(private)方法

ios - 将 pdf 的内容读取为字符串

ios - 投票功能实现

angular - 动画 *(星号)在高度值中的含义

iphone - 当带有核心数据的 UITableView 部分的最后一行被移动时 -> NSRangeException

javascript - 检测实际可用的计算和处理能力浏览器javascript

javascript - 网站上的动画故障