You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
5.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. # Lottie for iOS
  2. [![Version](https://img.shields.io/cocoapods/v/lottie-ios.svg?style=flat)](https://cocoapods.org/pods/lottie-ios) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![SwiftPM](https://img.shields.io/badge/SPM-supported-DE5C43.svg?style=flat)](https://swift.org/package-manager/) [![License](https://img.shields.io/cocoapods/l/lottie-ios.svg?style=flat)](https://cocoapods.org/pods/lottie-ios) [![Platform](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fairbnb%2Flottie-ios%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/airbnb/lottie-ios) [![Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fairbnb%2Flottie-ios%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/airbnb/lottie-ios)
  3. **View documentation, FAQ, help, examples, and more at [airbnb.io/lottie](http://airbnb.io/lottie/)**
  4. Lottie is a cross-platform library for iOS, macOS, tvOS, [Android](https://github.com/airbnb/lottie), and [Web](https://github.com/airbnb/lottie-web) that natively renders vector-based animations and art in realtime with minimal code.
  5. Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with [bodymovin](https://github.com/bodymovin/bodymovin), Sketch with [Lottie Sketch Export](https://github.com/buba447/Lottie-Sketch-Export), and from [Haiku](https://www.haiku.ai).
  6. Designers can create **and ship** beautiful animations without an engineer painstakingly recreating it by hand.
  7. Since the animation is backed by JSON they are extremely small in size but can be large in complexity!
  8. Animations can be played, resized, looped, sped up, slowed down, reversed, and even interactively scrubbed.
  9. Lottie can play or loop just a portion of the animation as well, the possibilities are endless!
  10. Animations can even be ***changed at runtime*** in various ways! Change the color, position, or any keyframable value!
  11. Here is just a small sampling of the power of Lottie
  12. ![Example1](_Gifs/Examples1.gif)
  13. ![Example2](_Gifs/Examples2.gif)
  14. <img src="_Gifs/Community 2_3.gif" />
  15. ![Example3](_Gifs/Examples3.gif)
  16. ![Abcs](_Gifs/Examples4.gif)
  17. ## Installing Lottie
  18. Lottie supports [Swift Package Manager](https://www.swift.org/package-manager/), [CocoaPods](https://cocoapods.org/), and [Carthage](https://github.com/Carthage/Carthage) (Both dynamic and static).
  19. ### Github Repo
  20. You can pull the [Lottie Github Repo](https://github.com/airbnb/lottie-ios/) and include the `Lottie.xcodeproj` to build a dynamic or static library.
  21. ### Swift Package Manager
  22. To install Lottie using [Swift Package Manager](https://github.com/apple/swift-package-manager) you can follow the [tutorial published by Apple](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) using the URL for the Lottie repo with the current version:
  23. 1. In Xcode, select “File” → “Swift Packages” → “Add Package Dependency”
  24. 1. Enter https://github.com/airbnb/lottie-ios.git
  25. ### CocoaPods
  26. Add the pod to your Podfile:
  27. ```ruby
  28. pod 'lottie-ios'
  29. ```
  30. And then run:
  31. ```ruby
  32. pod install
  33. ```
  34. After installing the cocoapod into your project import Lottie with
  35. ```swift
  36. import Lottie
  37. ```
  38. ### Carthage
  39. Add Lottie to your Cartfile:
  40. ```
  41. github "airbnb/lottie-ios" "master"
  42. ```
  43. And then run:
  44. ```
  45. carthage update
  46. ```
  47. In your application targets “General” tab under the “Linked Frameworks and Libraries” section, drag and drop lottie-ios.framework from the Carthage/Build/iOS directory that `carthage update` produced.
  48. ### Data collection
  49. The Lottie SDK does not collect any data. We provide this notice to help you fill out [App Privacy Details](https://developer.apple.com/app-store/app-privacy-details/).
  50. ## Contributing
  51. We always appreciate contributions from the community. To make changes to the project, you can clone the repo and open `Lottie.xcworkspace`. This workspace includes:
  52. - the Lottie framework (for iOS, macOS, and tvOS)
  53. - unit tests and snapshot tests (for iOS, must be run on an iPhone 8 simulator)
  54. - an Example iOS app that lets you browse and test over 100 sample animations included in the repo
  55. All pull requests with new features or bug fixes that affect how animations render should include snapshot test cases that validate the included changes.
  56. - To add a new sample animation to the snapshot testing suite, you can add the `.json` file to `Tests/Samples`. Re-run the snapshot tests to generate the new snapshot image files.
  57. - To update existing snapshots after making changes, you can set `isRecording = true` in `SnapshotTests.swift` and then re-run the snapshot tests.
  58. The project also includes several helpful commands defined in our [Rakefile](https://github.com/airbnb/lottie-ios/blob/master/Rakefile). To use these, you need to install [Bundler](https://bundler.io/):
  59. ```bash
  60. $ sudo gem install bundle
  61. $ bundle install
  62. ```
  63. For example, all Swift code should be formatted according to the [Airbnb Swift Style Guide](https://github.com/airbnb/swift). After making changes, you can reformat the code automatically using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) and [SwiftLint](https://github.com/realm/SwiftLint) by running `bundle exec rake format:swift`. Other helpful commands include:
  64. ```bash
  65. $ bundle exec rake build:all # builds all targets for all platforms
  66. $ bundle exec rake build:package:iOS # builds the Lottie package for iOS
  67. $ bundle exec rake test:package # tests the Lottie package
  68. $ bundle exec rake format:swift # reformat Swift code based on the Airbnb Swift Style Guide
  69. ```