Jimmy's iOS
iOS) Lottie-Animation 적용하기 본문
Lottie 는 에어비앤비사에서 개발한 라이브러리로 adobe after effects로 만든 애니메이션을 IOS에서(다른 플랫폼도 가능) 손쉽게 사용하게끔 도와주는 라이브러리 이다.
먼저 cocoapod 을 통해서 lottie 를 설치해준다!
pod 'lottie-ios'
lottie-animation 간단 구현하기
import UIKit
import Lottie
class ViewController : UIViewController {
//MARK: - Properties
private let lottieView : AnimationView = { // AnimationView 는 lottie 에서 제공해주는 뷰 이다.
let v = AnimationView()
return v
}()
//MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
configureUI()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
setLottieAnimaiton()
}
//MARK: - Functions
private func setLottieAnimaiton() {
let animationView = AnimationView(name: "money") // lottie 파일 이름을 넣어준다.
lottieView.contentMode = .scaleAspectFit
lottieView.addSubview(animationView)
animationView.frame = lottieView.bounds
animationView.loopMode = .loop // 반복 횟수 정하는 곳
animationView.play()
}
}
setLottieAnimation() 함수를 만든뒤 viewDidLoad() 가 끝난 viewDidAppear() 메소드안에서 실행을 시켜준다.
'iOS' 카테고리의 다른 글
iOS) 다크모드 & 라이트 모드 막기 (0) | 2021.10.03 |
---|---|
iOS) UINavigationController 왼쪽 스크롤 제스쳐로 팝업 구현 (0) | 2021.09.27 |
iOS) 앱 최신버전 체크 및 업데이트 하러 가기 (0) | 2021.09.14 |
iOS) Swift 애플산돌고딕네오(AppleSDGothicNeo) 폰트 적용하기 (0) | 2021.09.01 |
iOS) CATransition 을 사용하여 뷰 컨트롤러 fade in , fade out 시키기 (0) | 2021.07.19 |