From a0dc433a82a652bc97c41bf49e47c82953ee9802 Mon Sep 17 00:00:00 2001 From: kgaidis Date: Wed, 25 Apr 2018 11:47:04 -0400 Subject: [PATCH] fixed a bug where setting CABasicAnimation beginTime would cause the animation to be delayed --- lottie-ios/Classes/Private/LOTAnimationView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lottie-ios/Classes/Private/LOTAnimationView.m b/lottie-ios/Classes/Private/LOTAnimationView.m index 718b5e0b7e..59d5e13fec 100644 --- a/lottie-ios/Classes/Private/LOTAnimationView.m +++ b/lottie-ios/Classes/Private/LOTAnimationView.m @@ -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;