티스토리 뷰

오늘은 Lottie를 사용해보겠습니다.

Lottie는 Json 기반의 Adobe After Effects 애니메이션을 랜더링할 수 있는 라이브러리 입니다. 

사용을 위해서는 lottie-ios 라이브러리의 설치가 필요합니다.

자세한 설치법은 다음 링크에서 확인해주세요!

 

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

 

사용 방법

1. 설치가 끝난 후, import Lottie를 위에 입력합니다.

2. 로티 애니메이션 json 파일을 프로젝트에 추가 해줍니다.

3. 다음과 같이 설정해줍니다.

func setAnimation() {
	let animationView = AnimationView(name: "example")
	animationView.frame = view.bounds
	animationView.contentMode = .scaleAspectFill
	view.addSubview(animationView)
    
	animationView.play()
	animationView.loopMode = .loop
	//animationView.pause()
}

- 파일 이름을 AnimationView(name:) 에 적은 후, AnimationView의 크기를 지정합니다.

- animationView.play()를 하면 애니메이션이 실행 되고, loopMode를 .loop으로 지정하면 무한 반복하게 됩니다.

- pause()를 하게 되면 애니메이션이 종료됩니다.

 

실행 결과

애니메이션이 잘 실행되는 것을 확인할 수 있습니다!

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
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 27
28 29 30 31
글 보관함