GithubHelp home page GithubHelp logo

askari01 / gradientloadingbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fxm90/gradientloadingbar

0.0 2.0 0.0 21 KB

An animated gradient loading bar.

Home Page: https://github.com/fxm90/GradientLoadingBar

License: MIT License

Ruby 6.09% Objective-C 4.32% Swift 89.59%

gradientloadingbar's Introduction

GradientLoadingBar

Swift3.0 Version

An animated gradient loading bar. Inspired by iOS Style Gradient Progress Bar with Pure CSS/CSS3.

Example

Integration

GradientLoadingBar can be added to your project using CocoaPods by adding the following line to your Podfile:

pod 'GradientLoadingBar', '~> 1.0'

How to use

To get started you need to import GradientLoadingBar. After that you can use GradientLoadingBar.sharedInstance() to retrieve an instance to the loading bar. To show it, simply call the show() method and after you're done call hide().

// Show loading bar
GradientLoadingBar.sharedInstance().show()

// Do e.g. server calls etc.

// Hide loading bar
GradientLoadingBar.sharedInstance().hide()

Configuration

You can overwrite the default configuration by calling the initializers with the optional params height, durations and gradientColors:

let loadingBar = GradientLoadingBar(
    height: 1.0,
    durations: Durations(fadeIn: 1.0, fadeOut: 2.0, progress: 3.0)
    gradientColors: [
        UIColor(hexString:"#4cd964").cgColor,
        UIColor(hexString:"#ff2d55").cgColor
    ]
)

For custom colors you have to pass an array with CGColor values. For creating those colors you can use all initializers for UIColor mentioned here: UIColor+Initializers.swift

Custom shared instance

If you don't want to save the instance on a variable and use the singleton instead, you can use the saveInstance() method. Add the following code to your app delegate didFinishLaunchingWithOptions method:

GradientLoadingBar(
    height: 3.0,
    durations: Durations(fadeIn: 1.0, fadeOut: 2.0, progress: 3.00),
    gradientColors: [
        UIColor(hexString:"#4cd964").cgColor,
        UIColor(hexString:"#ff2d55").cgColor
    ]
).saveInstance()

After that you can use GradientLoadingBar.sharedInstance() as mentioned above.

Usage with PromiseKit

Check out my GitHub Gist on how to easily use GradientLoadingBar with PromiseKit.

Version

1.1.1

Author

Felix Mau (contact(@)felix.hamburg)

gradientloadingbar's People

Contributors

fxm90 avatar

Watchers

James Cloos avatar Farrukh Askari 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.