【问题标题】:CABasicAnimation change duration/speed during rotationCABasicAnimation 在旋转期间改变持续时间/速度
【发布时间】:2011-10-04 17:48:24
【问题描述】:

我正在使用 CABasicAnimation 永久旋转 imageView,并且我想在旋转期间更改旋转速度。有人可以帮我吗? 提前致谢!

【问题讨论】:

    标签: rotation cabasicanimation


    【解决方案1】:

    你可以看到https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW2

    我使用这个代码。

    Objective-C

    self.layer.timeOffset = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil]; 
    self.layer.beginTime = CACurrentMediaTime(); 
    self.layer.speed= theSpeedYouWant;
    

    斯威夫特

    self.layer.timeOffset = self.layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
    self.layer.beginTime = CACurrentMediaTime();
    self.layer.speed = speed;
    

    【讨论】:

      【解决方案2】:

      您可以以不同的速度开始一个新的基本动画,并将您从表示层收到的那个作为开始值。

      【讨论】:

      • 怎么做?你能写一个例子吗
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 2012-01-25
      • 2012-04-07
      • 2020-02-11
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      相关资源
      最近更新 更多