Code Monkey home page Code Monkey logo

dotlottie-ios's Introduction

dotLottie-ios

CI Status Version License Platform

Introducing dotLottie

⚠️ This repository is not longer maintained. Please use the latest dotlottie-ios here.

dotLottie is an open-source file format that aggregates one or more Lottie files and their associated resources into a single file. They are ZIP archives compressed with the Deflate compression method and carry the file extension of ".lottie".

View documentation, FAQ, help, examples, and more at dotlottie.io

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 5.0
  • iOS 9
  • macOS 10.12
  • tvOS 10.0

Installation

Cocoapods

dotLottie-ios is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'dotLottie'

Swift Package Manager

.package(url: "https://github.com/dotlottie/dotlottie-ios.git", from: "0.1.7")

Using dotLottie

import Lottie
import dotLottie
Enabling log
DotLottie.isLogEnabled = true
Loading from a local file
let animationView = AnimationView()

DotLottie.load(name: "animation") { (animation) in
    if let animation = animation {
        self.animationView.animation = animation
        self.animationView.bounds = CGRect(x: 0, y: 0, width: 300, height: 300)
        self.animationView.center = self.view.center

        self.view.addSubview(self.animationView)
        self.animationView.play()
    }else{
       print("Error loading .lottie")
    }
}
Loading a remote file
let animationView = AnimationView()

DotLottie.load(from: URL(string:"https://dotlottie.io/sample_files/animation.lottie")!){ (animation) in
    if let animation = animation {
        self.animationView.animation = animation
        self.animationView.bounds = CGRect(x: 0, y: 0, width: 300, height: 300)
        self.animationView.center = self.view.center

        self.view.addSubview(self.animationView)
        self.animationView.play()
    }else{
       print("Error loading .lottie")
    }
}

SwiftUI

Loading a local file
import SwiftUI
import dotLottie

struct LocalAnimationView: View {
    @State var name: String
    @State var play: Int = 1
    
    var body: some View {
        DotLottieView(name: name, play: self.$play, onCompleted: { completed in
            // handle completion
        })
        .frame(height:200)
    }
}
Loading file from a remote source
import SwiftUI
import dotLottie

struct RemoteAnimationView: View {
    @State var url: URL
    @State var play: Int = 1
    
    var body: some View {
        DotLottieView(url: url, play: self.$play, onCompleted: { completed in
            // handle completion
        })
        .frame(height:200)
    }
}

Author

Evandro Harrison Hoffmann | [email protected]

License

dotLottie-ios is available under the MIT license. See the LICENSE file for more info.

dotlottie-ios's People

Contributors

eharrison avatar whit3hawks avatar jawish avatar leonardo-ferreira07 avatar samuelosborne avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.