iOS 응용 (swift)
[iOS - swift] Lottie 프레임워크 (애니메이션)
jake-kim
2021. 1. 24. 16:14
Lottie 란
- Json 기반의 Adobe After Effects 에니메이션 구문을 분석하여 화면에 에니메이션을 렌더링해주는 프레임워크
- 플랫폼이 달라도 iOS, Android, Web 공통사용 가능

사용방법
- 종속성
pod 'lottie-ios'
- resource 무료 제공 사이트: lottiefiles.com/recent
LottieFiles - Free animation files built for Lottie
LottieFiles is a collection of animations designed for Lottie - gone are the days of bugging your developer
lottiefiles.com
- .json 파일을 받은 후 프로젝트에 추가
- 아래와 같이 사용 가능
import UIKit
import Lottie
class ViewController: UIViewController {
@IBOutlet weak var view1: UIView!
override func viewDidLoad() {
super.viewDidLoad()
let animationView = AnimationView(name: R.file.giftBoxJson.name) // R.swift 프레임워크 적용
animationView.frame = view1.bounds
animationView.contentMode = .scaleAspectFill
view1.addSubview(animationView)
animationView.play() // 애니메이션 시작
animationView.loopMode = .loop // 무한 재생
// animationView.pause() // 종료
}
}
* 참고: lottiefiles.com/recent