Skip to content
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

Multiple animations? #33

Open
adamcollingburn opened this issue May 13, 2022 · 7 comments
Open

Multiple animations? #33

adamcollingburn opened this issue May 13, 2022 · 7 comments

Comments

@adamcollingburn
Copy link

Hey Taehyun!

Not really an issue - but a question. Would it be possible to have multiple animations on the splash screen?

Essentially we'd like to have our logo centered (which is currently possible)

But then add one animation fixed to the top and another one to the bottom?

splash_psd___25___20_copy__CMYK_8___

I can do this on a screen with 3 x LottieView's but it'd be great to get them in a splash screen

Thanks

@danielsousast
Copy link

I needed to do that too. I managed to add 3 subviews.

let animationView = AnimationView();
let subView = AnimationView(name: lottieFile);
animationView.addSubview(subView);

In this case you return the parent animation view to the AppDelegate

@adamcollingburn
Copy link
Author

adamcollingburn commented May 17, 2022

Thanks so much @danielsousast! I give this a go now

@adamcollingburn
Copy link
Author

adamcollingburn commented May 17, 2022

animationView.addSubview(subView);

Hey @danielsousast - I just tried this, build is successful with no errors but no animation is played:

@objc func createAnimationView(rootView: UIView, lottieName: String) -> AnimationView {
    let animationView = AnimationView();
    let logo = AnimationView(name: lottieName);
    animationView.addSubview(logo);
    animationView.frame = rootView.frame;
    animationView.center = rootView.center;
    animationView.backgroundColor = UIColor(red: 0.27, green: 0.30, blue: 0.38, alpha: 1.00);
    return animationView;
  }

Could you possibly share a more in-depth example?

@HwangTaehyun
Copy link
Owner

Oh, that's very interesting! I will check this weekend!

@Haianh9999
Copy link

@HwangTaehyun Do I have to configure anything more in the launchscreen.storyboard file in ios?

@Haianh9999
Copy link

On my ios, the animated screen does not appear 🙇

@luudz
Copy link

luudz commented Mar 20, 2023

This worked for me:

Not sure if there's something better.

@objc func createAnimationView(rootView: UIView, lottieName: String) -> AnimationView {
    let splashView = AnimationView() //Container view
    let animationView = AnimationView(name: lottieName) //Main and longest animation
    let stampView = AnimationView(name: "secondaryAnimation") //Second animation
    
    animationView.frame.size = CGSize(width: 240, height: 128)
    animationView.center = rootView.center
    animationView.play(
      completion: { (success) in
        RNSplashScreen.setAnimationFinished(true) //Added "play" function and completion option
      }
    )
    
    stampView.frame.size = CGSize(width: 240, height: 128)
    stampView.center = rootView.center
    stampView.frame = CGRect(x: rootView.frame.size.width/2-120 , y: rootView.frame.size.height-130, width: 240, height: 128)
    stampView.play()
    
    splashView.addSubview(animationView);
    splashView.addSubview(stampView);
    splashView.frame = rootView.frame
    splashView.center = rootView.center
    splashView.backgroundColor = UIColor(red: 255, green: 0, blue: 0, alpha: 1)
    
    return splashView;
  }

  @objc func play(animationView: AnimationView) {
    animationView.play();
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants