Lottie Animation in SwiftUI
Lottie is an open source animation file format that’s tiny, high quality, interactive, and can be manipulated at runtime. It has a the largest community of designers and developers. App like Duolingo and headspace are using lottie animation extensively. In this article, you will learn how to add animated view using Lottie in SwiftUI. You can find the animations in Lottie files and it can be exported to the JSON format. Just drag the downloaded json in your app. Lottie animation is rendered in real time. Lottie is open source library for iOS, Android and more. Step 1: Follow the installation guideline available here. You can install it using cocoapods. Step 2: Add your Lottie animation json file next to Info.plist. Step 3: Create a UIViewRepresentable for Lottie animation view. Step 4: We will pass animationName, loopMode and speed. Only animation name is mandatory so we will add a check if name is empty or not. By default speed is 1. Those are the available library provided loop mode – Step 5: Create an animated view inside the makeUIView function and play the animation. Constraints are added as well which will take the full width and height of the container.…