Giter Site home page Giter Site logo

kvspinnerview's Introduction

KVSpinnerView

KVSpinnerView is highly customizable progress HUD with a possibility to show messages or progress while some work is being done. KVSpinnerView has several animation types which was written using CAAnimations.

alt text alt text

Installation

Cocoa Pods

Using CocoaPods is highly recommended way you should use to add KVSpinnerView to your project

  1. Add this line to your Podfile pod 'KVSpinnerView', '~> 1.0.2'

  2. Close .xcodeproj -> Open terminal -> Open project directory -> run pod install

  3. Import KVSpinnerView where needed (import KVSpinnerView)

Manual installation

  1. Download latest code version

  2. Copy KVSpinnerView directory into your project

Usage

You can use KVSpinnerView methods while some tasks are being done in background, some big tasks are loading, etc. To show KVSpinnerView on your screen you should use its static methods.

KVSpinnerView.show()
self.doSomeTask().response { (object) in
	DispatchQueue.main.async {
		KVSpinnerView.dismiss()
	}
}

You also can add status message while KVSpinnerView is being shown. Background rectangle of KVSpinning view will automatically expand regarding to message width.

KVSpinnerView.show(saying: "Hello")

Use this method to remove SKSpinnerView after several seconds.

KVSpinnerView.dismiss(after: 5.0)

There is two ways to add KVSpinner view to your screen:

  1. Use method KVSpinnerView.show() to add spinner to UIApplication's window. If you use this method then the spinner will be at screen untill you dismiss it.

  2. Use method KVSpinnerView.show(on: _) to add the spinner to a view you choose, e.g.:

class ViewController: UIViewController {
	override func viewDidLoad() {
        super.viewDidLoad()
		KVSpinnerView.show(on: self.view)
    }
}

To hanle a progress of current request you need to call 'KVSpinnerView.showProgress()' instead of showProgress() method and then you should call 'KVSpinnerView.handle(progress: progress)' method in downloadProgress handler:

KVSpinnerView.showProgress()
self.doSomeTask().downloadProgress { progress in
	DispatchQueue.main.async {
		KVSpinnerView.handle(progress: progress)
	}
	.response { response in
		DispatchQueue.main.async {
			KVSpinnerView.dismiss()
		}
	}
}

Customize

Also KVSpinnerView is highly customizable. You can customize it by changing KVSpinnerView.settings parameters, such as:

  • animationStyle - type of Spinner's animation. For now there are 2 variants: standart(default) and infinite

  • spinnerRadius- radius of KVSpinnerView. Background rectangle changes its size regarldess to this parameter

  • linesWidth - width of each animating line

  • linesCount - total count of KVSpinnerView animating lines

  • backgroundOpacity - opacity of background rectangle

  • tintColor - color of each animating line

  • backgroundRectColor - color of background rectangle

  • statusTextColor - color of status message text

  • minimumDismissDelay - KVSpinnerView will not be removed earlier than this parameter (in seconds)

  • animationDuration - duration of one spin of animating lines

  • fadeInDuration - duration of fade in of background rectangle

  • fadeOutDuration - duration of fade out of background rectangle

Screenshots

Purple

Gray

Purple

To do

  • Add several animation types
  • Add success and error animations with status messages

Licence

This code is distributed under the terms and conditions of the MIT license

kvspinnerview's People

Contributors

kuznetsovvladislav avatar lehlohonoloisaac 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.