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!
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;
You can start a new basic animation with different speed and take as the start value the one you receive from the presentation layer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With