GitXplorerGitXplorer
y

LottieSwiftUI

public
10 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
643c6940c26543dbed461b76a323da73d9c25c3b

Update sample.gif

yyarspirin committed a year ago
Unverified
2b006b58ec0419277afae8c0e451f1a99d4e3ba4

Fix typo and add sample gif

yyarspirin committed a year ago
Unverified
7eec6685fdf434b7b31a721860b50646cb15e178

Update README.md

yyarspirin committed a year ago
Unverified
122bc194f0396e4489af0873f06eb6f800d7ad65

Remove unverified features

yyarspirin committed a year ago
Unverified
a23a6b18866a2cb204c2a5c3cc60a93f07a40d35

Make use of required init

yyarspirin committed a year ago
Unverified
5a0ee0acd756315155f15445cd681005049f061a

Hide implementation details

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.