Render Lottie to UIImage with .coreAnimation #1769
-
Render Lottie to the UIImage is not working correctly when I use the ".coreAnimation" rendering engine. let view: LottieAnimationView = LottieAnimationView(name: "Any Lottie") When the rendering engine is .mainThread, the image is correct. On case .coreAnimation all Lottie components' x and y coordinates are (0, 0). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is a known problem with the Core Animation rendering engine. The CA engine animates by playing There are two possible workarounds:
I believe this is a fundamental limitation from using |
Beta Was this translation helpful? Give feedback.
This is a known problem with the Core Animation rendering engine.
The CA engine animates by playing
CAAnimation
s. These animations don't actually affect the appearance of the animation view'slayer
-- they only affect the appearance of the view'slayer.presentation()
. Because of this, the view appears blank when rendered usingview.layer.render(in:)
.There are two possible workarounds:
view.layer.presentation()?.render(in:)
instead. The presentation layer is only available if the view is currently being rendered on-screen in aUIWindow
. This is probably not a problem in most application use cases, but can be tricky in headless use cases like snapshot testing (we've…