-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to replace colors #236
Comments
We are working on it! |
+1 |
Is there a way to access a layer by name in Swift in order to manipulate properties such as color directly on the CALayer? |
any updates with this issue? |
So far I have only been able to accomplish this in a round-about way which looks something like: To find the highest level of layers. and then targeting the specific layer I want to change the color of with something like: and then finding the inner CAShapeLayer using: and then finally setting the color: It works but is less than ideal and may need to be restructured if the JSON changes. |
Should be out this week! |
Version 2 is out and you can now dynamically change ANY attribute at runtime. Example: |
UPDATE: I realized I was missing the key ".Color" that's value is changing at the end. So the following works! I'm getting an error while attempting to change the fill colors in my Lottie Animation using this new feature: |
One more notable issue I'm having with this latest feature, that wasn't occurring before, is now that I'm targeting multiple fills in the JSON (i.e. outer_circle_fill and inner_circle_fill) and multiple Lottie instances I am having problems retaining the set color after playing the animation. I have multiple instances of Lottie on a map at a time and colors set on one instance often switch to a color on another instance after the animation plays. This occurs even when I attempt to set every frame with the color (using a for loop.) Basically the fill color that I set using setValue changes to another color after I play the animation. This incorrect color appears to be coming from colors that are set on other Lottie instances on the screen and not the color I set for that particular instance. |
You need to include the property to change in the keypath I just fixed the instance color bug in 2.0.2! |
I should probably add some logging of warnings instead of the crash for wrong keypaths. |
Quick question, how would I know the layer names if I were to change the color of the keyPaths? Is there any method I can call to find out the keyPaths in Swift? Edit: Got the solution. Thanks anyways 👍 |
Duplicate of # How u got to know the layer name |
@chaitanya-ramji Yes! If you initialize a |
I'm trying to call
I'm also not sure which keypath to choose. |
Hmmm. I think that theres something wrong with logHierarchyKeypaths, clearly its missing some information. Do you have access to the after effects file? |
Thanks for your response. |
Is there a way to get the value using I tried |
@RishabhTayal did you ever get it to work? |
@ben5516 No I did not. |
You're missing the |
Also FYI everyone a new api has been built for this and will replace the existing one in the next release (2.5) |
The Android SDK (https://github.com/airbnb/lottie-android) seems to have support for replacing colors in an animation through filters. Would be nice to get the same functionality for the iOS SDK. One use case would be if you want to use the same animation in several different apps with distinct branding and colors. Currently this can only be achieved by having duplicated JSONs (overhead) or hot-swapping the colors in the JSON string at runtime (brittle).
The text was updated successfully, but these errors were encountered: