An animated label for displaying numbers

Overview

RollingDigitsLabel

A simple label that animates a number with each digit falling into place.

Various example labels

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/nchiu/RollingDigitsLabel", from: "1.0.0")
]

Initialization

In Code

let animatedLabel = RollingDigitsLabel(frame: .zero)

In Interface Builder

Drag a new UIView on to the canvas and set its class and module in the Identity inspector. Interface Builder configuration

Configuration

Set the label style

Color and font can be adjusted using these functions

animatedLabel.set(color: .systemTeal)
animatedLabel.set(font: .systemFont(ofSize: 30, weight: .semibold))

Set the NumberFormatter style

Common formatting adjustments can be made to the label directly...

animatedLabel.numberStyle = .currency
animatedLabel.minimumIntegerDigits = 5
animatedLabel.maximumIntegerDigits = 10
animatedLabel.minimumFractionDigits = 3
animatedLabel.maximumFractionDigits = 6

... or an existing NumberFormatter can be applied to the label.

let myFormatter = NumberFormatter()
animatedLabel.setNumberFormatter(myFormatter)

Animation

Set the number value of the label

animatedLabel.setNumber(newValue, animated: true, completion: { print("animation complete") })

newValue can be a Double, Int, Float, or NSNumber.

Adjusting the animation timing

You can change the duration, delay, spring damping, and initial velocity of the animation.

animatedLabel.setAnimation(duration: 0.75, delay: 0, springDamping: 0.85, initialVelocity: 0.5)

These values will be used every time a new number is set.

Example

import RollingDigitsLabel

class ViewController: UIViewController {
    
    @IBOutlet private var rollingDigitsLabel: RollingDigitsLabel? {
        didSet {
            rollingDigitsLabel?.numberStyle = .decimal
            rollingDigitsLabel?.set(font: .boldSystemFont(ofSize: 30))
            rollingDigitsLabel?.set(color: .systemMint)
        }
    }
    
    @IBAction func pressedNewNumber(_ sender: UIButton) {
        sender.isEnabled = false
        let newNumber = Int(arc4random() % 999999999)
        rollingDigitsLabel?.setNumber(newNumber, animated: true, completion: {
            sender.isEnabled = true
        })
    }
}

Example code running

You might also like...
Simple Animated tabbar with native control
Simple Animated tabbar with native control

SSCustomTabbar Simple Animated tabbar with native control. Requirements iOS 11.0+ Xcode 10.0+ Installation SSCustomTabbar doesn't contain any external

 AnimatedWaveform provides the user with an animated version of the waveform.circle SF Symbol in SwiftUI.
AnimatedWaveform provides the user with an animated version of the waveform.circle SF Symbol in SwiftUI.

AnimatedWaveform AnimatedWaveform is a Swift Package designed for SwiftUI. It provides the user with an animated version of the waveform.circle SF Sym

Animated Minimal Podcast App UI using SwiftUi 3.0 🤓
Animated Minimal Podcast App UI using SwiftUi 3.0 🤓

Minimal Podcast App UI Animated Minimal Podcast App UI using SwiftUi 3.0 🤓 Video Preview Screenshots Features SwiftUI 3D Card Animation SwiftUI Delay

ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.
ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

🚀  It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻  . Contributions are always welcome 🤗
🚀 It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻 . Contributions are always welcome 🤗

Taskey 🚀 What is Taskey 🤔 ? Taskey is an application build in SwiftUI to track your task with a beautiful animations and UI . Also used core data to

Appstore card animation transition. UICollectionView and UITableView card expand animated transition
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

Animated alert library like Swarm app.
Animated alert library like Swarm app.

TKSwarmAlert Animation Tool for Alert like Swarm app. ScreenShot Installation CocoaPods You can use CocoaPods to install TKSwarmAlert by adding it to

A macOS menu bar app for copy animated LIHKG stickers to clipboard.
A macOS menu bar app for copy animated LIHKG stickers to clipboard.

LIHKG GIFs A macOS menu bar app created for easily sending LIHKG stickers to Microsoft Teams. This app will try to load a GIF selected by user into th

Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Animated Mask Label is a nice gradient animated label.
Animated Mask Label is a nice gradient animated label.

Animated Mask Label Demo Screen Screenshot Demo/Example For demo: $ pod try AnimatedMaskLabel To run the example project, clone the repo, and run pod

NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or number morphing.
NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or number morphing.

NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or num

[iOS] Animated analog flip numbers like airport/train-station displays (SwiftUI)
[iOS] Animated analog flip numbers like airport/train-station displays (SwiftUI)

A SwiftUI FlipNumberView A small universal (iOS + macOS) app displaying the current time with a flip animation. This is still WIP and doesn't support

ANDLineChartView is easy to use view-based class for displaying animated line chart.
ANDLineChartView is easy to use view-based class for displaying animated line chart.

ANDLineChartView for iOS ANDLineChartView is easy to use view-based class for displaying animated line chart. Usage API is simple. Just implement foll

Showcase new features after an app update similar to Pages, Numbers and Keynote.
Showcase new features after an app update similar to Pages, Numbers and Keynote.

WhatsNew Description WhatsNew automatically displays a short description of the new features when users update your app. This is similar to what happe

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Handwriting numbers recognizer for Siri Remote
Handwriting numbers recognizer for Siri Remote

TvOSScribble TvOSScribble, based on CoreML, mitigates the lack of a physical numpad area in Siri Remote implementing a handwriting gesture recognizer.

Basic operations on numbers like +,-,/,*

OperationsOnNumbers Basic operations on numbers like +,-,/,* accept two numbers from textfields and pass it to another page after operations button cl

Comments
  • Feature request: Only animate digits that need to be changed

    Feature request: Only animate digits that need to be changed

    Currently, the animation always happens for all digits, counting from zero upwards. It would be nice if there was the option to only animate the digits that are changed, in order to create a more

    For example, when changing from "110.000,00" to "115.000,00", right now RollingDigitsLabel will visually animate all first 3 digits, while it would be cool if only the 3rd digit would change from "0" to "5".

    opened by jvanakker 0
Owner
Nathan Chiu
iOS Developer
Nathan Chiu
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 42 Oct 4, 2022
A slider widget with a popup bubble displaying the precise value selected written on Swift.

A slider widget with a popup bubble displaying the precise value selected written on Swift. We specialize in the designing and coding of

Ramotion 1.9k Dec 23, 2022
A framework and generator for displaying SwiftUI component libraries

Exhibition Exhibition is a framework and generator for displaying a SwiftUI component library. Inspired by Storybook and Showkase Installation Swift P

Malcolm Jarvis 23 Dec 30, 2022
Presentation helps you to make tutorials, release notes and animated pages.

Presentation helps you to make tutorials, release notes and animated pages.

HyperRedink 3k Dec 28, 2022
A simple animated progress bar in Swift

DSGradientProgressView Introduction DSGradientProgressView is a simple and customizable animated progress bar written in Swift. Inspired by GradientPr

Dhol Studio 445 Oct 13, 2022
Simple and powerful animated progress bar with dots

Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ Swift 3.0+ Installatio

Nikola Corlija 42 Dec 5, 2022
🚀 It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻 . Contributions are always welcome 🤗

Taskey ?? What is Taskey ?? ? Taskey is an application build in SwiftUI to track your task with a beautiful animations and UI . Also used core data to

Mohd Yasir 36 Nov 20, 2022
An animated trophy banner that looks like Xbox achievement 🏆

TrophyKit An animated trophy banner that looks like Xbox achievement. Demo demo.mov Usage Requirements iOS 14.0+ tvOS 14.0+ Swift 5.3+ Installation Tr

Yubo Qin 11 Jul 18, 2022
SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image

SwiftUI.AnimatedImage SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image Screen.Recording.2021-07-31.at.02.18.33.mov Insta

Marcin Krzyzanowski 50 Oct 14, 2022
Colorful - A SwiftUI implementation of AppleCard's animated colorful blur background.

Colorful - A SwiftUI implementation of AppleCard's animated colorful blur background.

Lakr Aream 200 Jan 3, 2023