ios - 动画停止时如何停止恢复到原始值

标签 ios objective-c cocoa-touch

我使用核心动画来制作动画 View 。当动画停止时, View 将恢复到它的原始值。我怎样才能停止恢复? 这是我的代码

   #define p(x,y) CGPointMake(x,y)
   #define v valueWithCGPoint
    ...
    CGPoint rectL=p(463, 473);
    CGPoint rectR=p(503, 473);
    NSValue *valueL = [NSValue v:rectL];
    NSValue *valueR = [NSValue v:rectR];
    NSArray *firstArray=@[valueL,valueR,valueL,valueR,valueL,valueR,valueL,valueR];

    CAKeyframeAnimation * theAnimation;

    // Create the animation object, specifying the position property as the key path.
    theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    theAnimation.values=firstArray;
    theAnimation.duration=5.0;
    //theAnimation.calculationMode= kCAAnimationLinear;
    // Add the animation to the layer.
    [self.boView.layer addAnimation:theAnimation forKey:@"moveBackAndForth"];

最佳答案

在添加动画之前设置最终值。动画包含所需的起始值,因此它将继续按照您的意愿工作。

关于ios - 动画停止时如何停止恢复到原始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16852807/

相关文章:

iphone - 当标签中的文本被限制为适合宽度时,如何计算 UIFont 的大小?

ios - 从NSNumber获取CGFloat的最常见和正确的做法是什么?

ios - iPhone 应用程序无法在模拟器中运行

objective-c - 将小数坐标转换成度、分、秒、方向

ios - 编译时错误: No known instance method for selector 'setDetailItem:'

ios - 我无法从自定义 UITableViewCell 中删除自定义 UIButton

ios - 滚动过去 UITableViewCell 查看新内容

ios - 使用解析获取错误(代码 : 105, 版本 : 1. 17.2)

php - iOS Xcode NSURL 参数太多

ios - 我可能不再用 atos 符号化崩溃日志