Adding animation to the iOS app is easier than ever!

Tram Ho

Animation is an indispensable part of mobile application. Combining animation with user interface (UI) and user experience design (UX) is essential, as it plays an important role in improving how people respond to applications or websites.

We can create animations simply by changing the position or size of frames. But to create complex and eye-catching animations is not easy. In this article, I will tell everyone about a useful library for animation, Lottie

1. Introduce Lottie

This is a library that supports both Android and iOS, which is used to simply render animations and art vectors. Lottie loads and renders animations and vectors from the bodymovin JSON file, this type of file can be created by After Effects, Sketch, … This will become a link between the developer and the designer very helpful.

2. Create demo application

Prepare json file:

If you can’t create the Json file yourself, you can go to Lottie ‘s homepage to download the desired animation.

Select the desired animation -> copy the code -> save as .json

Create project:

Create a single app with Xcode

Then add the json file you just created above to your project.

Add libraries to the project:

Next you need to create Podfile and add lottie. In the project I added the SnapKit library to support constraint views

Initialize Lottie View:

Creating a swift file to initialize the lottie view, here will load the json file and add some config for the view

Add view to Viewcontroller:

Next we return to the Viewcontroller file to initialize the object and add the supperView:

Result:

The results are as follows:

3. Conclusion

This is just a simple example of Lottie, and there are many other great things.

Find out more at: https://github.com/airbnb/lottie-ios

Share the news now

Source : Viblo