Skip to content

ScrollCounter is an iOS framework for getting a nice scrolling animation when transitioning between numbers. This framework is modeled after the animations seen in the Robinhood app.

License

modernistik/ScrollCounter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScrollCounter

Version License Platform

Installation

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

pod 'ScrollCounter'

Usage

ScrollCounter is a framework for getting a nice scrolling animation when transitioning between numbers. This framework is modeled after the animations seen in the Robinhood app.

Checkout this Medium article for a high-level look on how ScrollCounter works.

Single Digits

A scroll counter with a single digit can be created and animated in 2 lines:
// Initialize a scrolling counter for the standard range between 0-9 (other ranges can be used as well).
let singleDigit = DigitScrollCounter(font: UIFont(name: "Avenir-Black", size: 150)!, textColor: .white, backgroundColor: .black, scrollDuration: 0.3, gradientColor: .black, gradientStop: 0.2)

// Scrolls to the item at the 8th index.  For a DigitScrollCounter, this means scroll to the number 8.
singleDigit.scrollToItem(atIndex: 8)

Unbounded Numbers

Use a `NumberScrollCounter` to handle an unbounded range of numbers:
// Initialize a number counter, which is a view composed of `DigitScrollCounter`s.
let numberCounter = NumberScrollCounter(value: 1, scrollDuration: 0.33, decimalPlaces: 2, prefix: "$", suffix: "", font: font.withSize(40), textColor: .white, gradientColor: .black, gradientStop: 0.2)

// Set a new value.  This will trigger the animation to show the given value.
numberCounter.setValue(123.45)

About

ScrollCounter is an iOS framework for getting a nice scrolling animation when transitioning between numbers. This framework is modeled after the animations seen in the Robinhood app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%