iphone - 循环和中断动画

标签 iphone objective-c ios animation

我希望有人能告诉我循环动画、用另一个动画打断动画,然后恢复原始动画的正确方法。我目前设置动画的方式是这样的:

-(void) firstAnimation
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction) animations:^{
        CGPoint bottomPoint = CGPointMake(215.0, 380.0);
        imgBee.center = bottomPoint;
    } completion:^(BOOL finished) {

    }];
}

中断:

-(void) interruptAnimation
{

    CGPoint point1 = CGPointMake(500, 500);
    CGPoint originalCenter = CGPointMake(215.0, 410.0);
    [UIView animateWithDuration:2.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAutoreverse) animations:^{
        imgBee.center = point1;
    } completion:^(BOOL finished) {
        imgBee.center = originalCenter;
        [self firstAnimation];

    }];   
}

我很确定这不是解决此问题的最佳方法。当我用 interruptAnimation 中断时,原始动画突然开始,当我调用 [self firstAnimation] 时,动画也突然重新开始。

如果有任何帮助,我将不胜感激。

最佳答案

看看这个关于暂停和恢复动画的问答,这可能会有所帮助:QA1673

关于iphone - 循环和中断动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10650562/

相关文章:

iphone - 如何最好地构建基本 iPhone 表格/导航数据库应用程序的代码?

ios - 请求许可在 Swift 中解锁屏幕方向

ios - 如果已安装,如何将用户发送到 facebook 应用程序上的 facebook 页面?

iphone - PhoneGap - 针对远程网站进行身份验证的方法?

iphone - 在 iPhone 3G(非 S)上捕获相机帧缓冲区?

ios - firebase iOS 收不到推送通知

ios - 预期返回 'UIImage' 的函数中缺少返回值

iphone - 更改导航 Controller iphone的顺序

ios - 如何在 Objective-C 中将 PHAsset 转换为 UIImage

objective-c - 使用 ARC 从导航 Controller 弹出时保留 View Controller