iOS/UIKit

[Swift/UI Kit] Lottie 라이브러리 쓰기!

최지철 2023. 7. 1. 21:31
728x90
반응형

https://github.com/airbnb/lottie-ios

 

GitHub - airbnb/lottie-ios: An iOS library to natively render After Effects vector animations

An iOS library to natively render After Effects vector animations - GitHub - airbnb/lottie-ios: An iOS library to natively render After Effects vector animations

github.com

로티 깃허브 링크입니다. 전 PM으로 추가했습니다! 편하신대로 추가해주시고  아래 링크(로티공홈)에서 맘에 드는 gif파일을 고르거나 개인 파일을 골라 밑에 코드 처럼 적용하시면 되요!
https://lottiefiles.com

 

LottieFiles: Download Free lightweight animations for website & apps.

Effortlessly bring the smallest, free, ready-to-use motion graphics for the web, app, social, and designs. Create, edit, test, collaborate, and ship Lottie animations in no time!

lottiefiles.com

 

적용 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  let animationView: LottieAnimationView = {
        let animView = LottieAnimationView(name: "99228-heart2heart") //json 파일을 갖고와서 프로젝트에 추가해주세요!
        animView.contentMode = .scaleAspectFill
        return animView
    }()
    private func layout() {
        self.view.addSubview(animationView)
        
        // 애니메이션뷰의 제약 조건 설정
        animationView.snp.makeConstraints {
            $0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(60)
            $0.centerY.equalToSuperview()
        }
        
        animationView.play { [weak self] finished in
            guard let self = self else { return }
            
            // 애니메이션이 종료된 후에 이미지뷰와 버튼을 추가하고 제약 조건을 설정합니다.
            if finished {
                let sideniavigationController = UINavigationController(rootViewController: MainViewController())
                let LoginVC = sideniavigationController
                LoginVC.modalPresentationStyle = .fullScreen
                self.present(LoginVC,animated: true, completion: nil)
            }
        }
    }
cs

짜란

끝!

728x90
반응형