GithubHelp home page GithubHelp logo

countingview's Introduction

CountingView

Carthage compatible Swift 2.2

Inspired by UICountingLabel this is a swift version of an animated counting label.

Example

##Usage

To start the counting animation just call startCounting

label.startCounting(destinationValue: 100)

// with all available properties
label.startCounting(0,
		destinationValue: 1000,
      	duration: 3,
          method: .Linear,
	       progress: { value in
   		   	print(value)
      	},
      	completion: {
      		print("complete")
    	})

Format

By setting format you can also add a text.

label.format = "%@ Value"

Alternatively you can provide a NSNumberFormatter to define the format of the animated number.

    let formatter = NSNumberFormatter()
    formatter.minimumIntegerDigits = 5
    formatter.maximumFractionDigits = 0;
    formatter.numberStyle = .DecimalStyle
    formatter.groupingSeparator = "."
    
    linealLabel.numberFormatter = formatter

Custom AnimatedView

If you want to create your own animated views use the CountAnimatorclass.

let animator = CountAnimator(startValue: startValue, destinationValue: destinationValue, duration: duration, method: method)

animator.startCount({ value in
	if let formatedValue = self.numberFormatter.stringFromNumber(value) {
		self.text = String.localizedStringWithFormat(self.format, formatedValue)
		if let progress = progress {
			progress(value: value)
		}
	}
}, completion: {
	if let completion = completion {
		completion()
	}
})

This class also provide startCount with a progressand completionclosure.

Installation

Carthage

Add the following line to your Cartfile.

####Swift 2.3

github "wieweb/CountingView" ~> 1.1

####Swift 3.0

github "wieweb/CountingView" "swift3.0"

Then run carthage update.

Manually

Just drag and drop the two .swift files in the CountingView folder into your project.

Todo

  • Counting Button

countingview's People

Contributors

swieland avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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