m1ga / ti.animation

Airbnb Lottie + Rive animation module for Titanium SDK
Other
106 stars 20 forks source link

iOS: addViewToLayer not working #24

Closed Brianggalvez closed 7 years ago

Brianggalvez commented 7 years ago

trying to add a subview to the following animation [https://www.lottiefiles.com/558-rewards-icon] doesn't work.

$.lottie.addViewToLayer({
        view : Ti.UI.createView({
            height : 40,
            width : 40,
            backgroundColor : "red",
            zIndex : 4
        }),
        layer : "Star"
    });
m1ga commented 7 years ago

iOS? I didn't implement the feature on Android. I think it is not available in lottie-android

hansemannn commented 7 years ago

Please try the iOS 1.2.0 Beta.

Brianggalvez commented 7 years ago

Yes, iOS. Now it shows the view but not in the correct layer :

captura de pantalla 2017-09-09 a las 10 26 09

It should be inside the star.

Also the beta version only works with the 6.2.0.RC

hansemannn commented 7 years ago

It is expected to be there, as it's by default placed at a 0/0 rect inside the wrapper view. You will have to position it to the correct rect for your use-case. I need to check that, as well as the < 6.2.0 compatibility. What does not work? Simply saying something doesn't work doesn't bring us to a solution :).

EDIT: It was a dynamic library, which is only supported natively in Ti SDK 6.2.0+. Removed that and replaced it with the source-files again. Works now.

Brianggalvez commented 7 years ago

Yes sorry for not pointing it...

As I see in the exaple [http://airbnb.io/lottie/ios/addsubviews.html] it's correct, you have to manually position it, I thought it would be centered automatically.

Thanks!

EDIT:

I've added two methods that I found useful:

-(void)logHierarchyKeypaths:(id)unused
{
    [[self animationView] logHierarchyKeypaths];
}

But with this I cna only see the logs with iOS Console App.

- (void)setValueforKeypathAtFrame:(id)args
{
    ENSURE_UI_THREAD(setValueforKeypathAtFrame, args);
    ENSURE_DICT(args);

    id value = [args objectForKey:@"value"];
    id keypath = [args objectForKey:@"keypath"];
    id frame = [args objectForKey:@"frame"];

    TiColor *newColor = [TiUtils colorValue:value];
    if(newColor!=nil)
    {
        value = [newColor _color];
    }
    [[self animationView]setValue:value forKeypath:keypath atFrame:frame];
}

And this one, but I feel that we could miss some cases for the 'value' key. How I should proceed, wait for the 1.2.0 release and do a PR or should I do it now?

hansemannn commented 7 years ago

Please wait for the 1.2.0 release, thx.

hansemannn commented 7 years ago

Closing this issue as it's solved.