fixed a bug where setting CABasicAnimation beginTime would cause the animation to be delayed

This commit is contained in:
kgaidis
2018-04-25 11:47:04 -04:00
parent 23abc3a239
commit a0dc433a82

View File

@@ -336,7 +336,9 @@ static NSString * const kCompContainerAnimationKey = @"play";
animation.delegate = self;
animation.removedOnCompletion = NO;
if (offset != 0) {
animation.beginTime = CACurrentMediaTime() - (offset * 1 / _animationSpeed);
CFTimeInterval currentTime = CACurrentMediaTime();
CFTimeInterval currentLayerTime = [self.layer convertTime:currentTime fromLayer:nil];
animation.beginTime = currentLayerTime - (offset * 1 / _animationSpeed);
}
[_compContainer addAnimation:animation forKey:kCompContainerAnimationKey];
_compContainer.shouldRasterize = NO;