【问题标题】:What's the meaning of progress keypath in CABasicAnimation?CABasicAnimation中progress keypath的含义是什么?
【发布时间】:2017-03-31 21:13:35
【问题描述】:

来自https://github.com/danielamitay/DACircularProgress/blob/master/DACircularProgress/DACircularProgressView.m的代码sn-p

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"progress"];
animation.duration = duration;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fillMode = kCAFillModeForwards;
animation.fromValue = [NSNumber numberWithFloat:self.progress];
animation.toValue = [NSNumber numberWithFloat:pinnedProgress];
animation.beginTime = CACurrentMediaTime() + initialDelay;
animation.delegate = self;
[self.circularProgressLayer addAnimation:animation forKey:@"progress"];

但我在offical document 中找不到progress。键路径是否需要是可动画的属性? progress 是什么意思?

【问题讨论】:

  • 我认为您可能误读了代码。 forKey:@"progress" 正在“命名”动画。
  • 我指的是[CABasicAnimation animationWithKeyPath:@"progress"];中的progress
  • 糟糕!我的误读,不是你的!编辑前在屏幕外

标签: ios animation


【解决方案1】:

来自this answer(巧合的是progress的动画):

首先,我们需要创建一个新的 CALayer 子类,它有一个名为“progress”的动画属性。

您的 sn-p 确实有一个名为“progress”的属性

@property(nonatomic) CGFloat progress;

似乎动画正在为该属性设置动画

【讨论】:

    【解决方案2】:

    这是因为 progress 是这个特定 uiview 的动画属性。我们可以自定义动画属性参考:Create a custom animatable property

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 2017-11-10
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      相关资源
      最近更新 更多