GitXplorerGitXplorer
y

LottieSwiftUI

public
10 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
fef9a1e687f09ea2f96cc2a8d726b9435ffa24d9

Mention support for playback state in README.md

yyarspirin committed a year ago
Unverified
601e56a8d8309ce941bbf92b6a9631564778e2c5

Merge branch 'master' of https://github.com/mountain-viewer/LottieSwiftUI

yyarspirin committed a year ago
Unverified
e9871d482612170d34f98441cb4e748d8a3c74ae

Add support for playback state

yyarspirin committed a year ago
Verified
a05e11d285d5c9a8c40a629b479c7bf63139d3be

Update README.md

yyarspirin committed a year ago
Unverified
6ea12d2c97a3301c915dfdc968e5f41cca5e6c82

Update docs

yyarspirin committed a year ago
Verified
25c26d0169e7dbef7753ac796157638e8dd1e35a

Add example to README.md

yyarspirin committed a year ago

README

The README file for this repository.

LottieSwiftUI

A Swift package that provides a SwiftUI interface to the popular Lottie animation library. The LottieSwiftUI package allows you to easily add and control Lottie animations in your SwiftUI project. It offers a clean and easy-to-use API with customizable options like animation speed and loop mode.

Features

  • Swift/SwiftUI native integration.
  • Customize animation speed.
  • Choose loop mode: play once, loop, or auto reverse.
  • Control of animation playback (play, pause, stop).
  • Clean, organized, and thoroughly documented code.
  • Efficient and performance-optimized design.

Installation

This package uses Swift Package Manager, which is integrated with Xcode. Here's how you can add LottieSwiftUI to your project:

  1. In Xcode, select "File" > "Swift Packages" > "Add Package Dependency"
  2. Enter the URL for this repository (https://github.com/yarspirin/LottieSwiftUI)

Usage

Here's an example of how you can use LottieView in your SwiftUI code:

import SwiftUI
import LottieSwiftUI

struct ContentView: View {
  @State private var playbackState: LottieView.PlaybackState = .playing

  var body: some View {
    LottieView(
      name: "london_animation", // Replace with your Lottie animation name
      animationSpeed: 1.0,
      loopMode: .loop,
      playbackState: $playbackState
    )
  }
}

Properties:

  • name: The name of the Lottie animation file (without the file extension). This file should be added to your project's assets.
  • animationSpeed: The speed of the animation. It should be a CGFloat value, where 1.0 represents the normal speed. Defaults to 1.0.
  • loopMode: The loop mode for the animation. Default is LottieLoopMode.playOnce. Other options include .loop and .autoReverse.
  • playbackState: The playback state of the animation. It should be a Binding<PlaybackState>, allowing the state to be shared between multiple views. This allows for the control of the animation (play, pause, stop) from the parent view.

Controlling Animation Playback

To control the animation playback, pass a Binding to PlaybackState to LottieView. This will allow you to control the animation's state (play, pause, stop) from its parent view or any other part of your app. For example, you could bind it to a SwiftUI @State property, and then modify that state when a button is pressed to control the animation.

Requirements

  • iOS 13.0+
  • Xcode 14.0+
  • Swift 5.7+

Contributing

Contributions are welcome! If you have a bug to report, a feature to request, or have the desire to contribute in another way, feel free to file an issue.

License

LottieSwiftUI is available under the MIT license. See the LICENSE file for more info.