7

I am using CABasicAnimation to rotate forever an imageView and I want to change rotation speed during rotation. Can anybody help me with this? Thanks in advance!

leon4ic
  • 339
  • 4
  • 12

2 Answers2

4

You can see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW2

And I use this code.

Objective-C

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

Swift

self.layer.timeOffset = self.layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
self.layer.beginTime = CACurrentMediaTime();
self.layer.speed = speed;
Yu-Lin Wang
  • 131
  • 2
  • 5
2

You can start a new basic animation with different speed and take as the start value the one you receive from the presentation layer.

Bernd Rabe
  • 790
  • 6
  • 23