airbnb / lottie-ios

An iOS library to natively render After Effects vector animations
http://airbnb.io/lottie/
Apache License 2.0
25.7k stars 3.74k forks source link

Different CALayer performances of different types of Lottie #2352

Closed Yookiely closed 6 months ago

Yookiely commented 6 months ago

lottie-ios 4.3.0 I would like to use the following code to obtain a screenshot of Lottie View UIGraphicsBeginImageContextWithOptions(animationView.bounds.size, false, 0) if let context = UIGraphicsGetCurrentContext() { animationView.layer.render(in: context) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() } But it will exhibit different results due to different lottie types. If I use lottie with Base64 Image, I can't get the correct Image. Example.

issue_1800.json in Project Example

I want to have

image

but real...

image

And if I use the lottie source file which doesn't have base64 Img, It will be correct.

So why? Could the lottie source file with base64 Img use other way to get the correct snapshot?

Yookiely commented 6 months ago

BTW LottieAnimationLayer is also not work.

calda commented 6 months ago

Here is some discussion: https://github.com/airbnb/lottie-ios/discussions/1769#discussioncomment-3860672. This is a known limitation of the Core Animation rendering engine.