Incrementable UILabel for iOS and tvOS

Overview

IncrementableLabel

Travis Language CocoaPods Platform License

IncrementableLabel is the easiest way to have incrementable numbers in an UILabel!

Usage

let myIncrementableLabel = IncrementableLabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
myIncrementableLabel.incrementFromValue(0, toValue: 100, duration: 1)

Check the sample project for advanced usage

Installation

  • iOS 8.0+
  • tvOS 9.0+

CocoaPods Installation

IncrementableLabel is available on CocoaPods. Just add the following to your Podfile:

pod 'IncrementableLabel'

Swift Package Manager

IncrementableLabel is available on SPM. Just add the following to your Package file:

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/recisio/IncrementableLabel.git", majorVersion: 1)
    ]
)

Manual Installation

Just drag the Source/*.swift files into your project.

IncrementableLabel properties

var option: IncrementableLabelOptions = .linear

An options indicating how you want to perform the incrementation:

  • linear
  • easeIn
  • easeOut
  • easeInOut
typealias StringFormatter = (Float) -> String
var stringFormatter: StringFormatter?

typealias AttributedTextFormatter = (Float) -> NSAttributedString
var attributedTextFormatter: AttributedTextFormatter?

A callback closure which permits a greater control on how the text (attributed or not) is formatted between each incrementation.

var easingRate: Float = 3.0

The rate used when an option is used.

var format: String = "%d"

The format is used to set the text in the label. You can set the format to %f in order to display decimals.

public var currentValue: Double

The label's value during the incrementation

IncrementableLabel methods

func increment(fromValue: Float, toValue: Float, duration: Float = 0.3, fromColor: UIColor? = nil, toColor: UIColor? = nil, completion: IncrementableLabelCompletion? = nil)

Starts the incrementation fromValue to toValue, and the text color changes from fromColor to toColor. The duration by default will be 0.3

func incrementFromCurrentValue(toValue: Float, duration: Float = 0.3, fromColor: UIColor? = nil, toColor: UIColor? = nil, completion: IncrementableLabelCompletion? = nil)

Starts the incrementation from the current value to toValue. The duration by default will be 0.3

func incrementFromZero(toValue: Float, duration: Float = 0.3, fromColor: UIColor? = nil, toColor: UIColor? = nil, completion: IncrementableLabelCompletion? = nil)

Starts the incrementation from zero to toValue. The duration by default will be 0.3

What's next

  • Any suggestions?

Contribution

  • If you found a bug, open an issue
  • If you have a feature request, open an issue
  • If you want to contribute, submit a pull request

Licence

IncrementableLabel is available under the MIT license. See the LICENSE file for more info.

You might also like...
UILabel replacement with fine-grain appear/disappear animation

ZCAnimatedLabel UILabel-like view with easy to extend appear/disappear animation Features Rich text support (with NSAttributedString) Group aniamtion

MTLLinkLabel is linkable UILabel. Written in Swift.
MTLLinkLabel is linkable UILabel. Written in Swift.

# MTLLinkLabel is linkable UILabel. Written in Swift. Requirements iOS 8.0+ Xcode 7.3+ Installation Carthage You can install Carthage with Homebrew. $

Adds animated counting support to UILabel.
Adds animated counting support to UILabel.

UICountingLabel Adds animated counting support to UILabel. CocoaPods UICountingLabel is available on CocoaPods. Add this to your Podfile: pod 'UICount

A faster and more flexible label view for iOS

STULabel is an open source iOS framework for Swift and Objective-C that provides a label view (STULabel), a label layer (STULabelLayer) and a flexible

 A triangle shaped corner label view for iOS written in Swift.
A triangle shaped corner label view for iOS written in Swift.

A triangle shaped corner label view for iOS written in Swift. This view is a subclass of UIView. It can be created and customized from the Storyboard

High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

Simple countdown UILabel with morphing animation, and some useful function.
Simple countdown UILabel with morphing animation, and some useful function.

CountdownLabel Simple countdown UILabel with morphing animation, and some useful function. features Simple creation Easily get status of countdown fro

A drop-in replacement for UILabel that supports attributes, data detectors, links, and more

TTTAttributedLabel A drop-in replacement for UILabel that supports attributes, data detectors, links, and more TTTAttributedLabel is a drop-in replace

UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.
UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.

THLabel THLabel is a subclass of UILabel, which additionally allows shadow blur, inner shadow, stroke text and fill gradient. Requirements iOS 4.0 or

A simple designable subclass on UILabel with extra IBDesignable and Blinking features.
A simple designable subclass on UILabel with extra IBDesignable and Blinking features.

JSLabel Demo pod try JSLabel ...or clone this repo and build and run/test the JSLabel project in Xcode to see JSLabel in action. If you don't have Coc

 Glitching UILabel for iOS 📺
Glitching UILabel for iOS 📺

Glitching UILabel for iOS 📺 Created by Lee Sun-Hyoup. Try the sample $ pod try GlitchLabel Requirements iOS 8.0+ Swift 3 Xcode 8 Installation CocoaP

A handy class for iOS to use UILabel as a countdown timer or stopwatch just like in Apple Clock App.
A handy class for iOS to use UILabel as a countdown timer or stopwatch just like in Apple Clock App.

MZTimerLabel Purpose MZTimerLabel is a UILabel subclass, which is a handy way to use UILabel as a countdown timer or stopwatch just like that in Apple

Highlighter will magically find UI objects such as UILabel, UITextView, UITexTfield, UIButton
Highlighter will magically find UI objects such as UILabel, UITextView, UITexTfield, UIButton

Highlighter Updates See CHANGELOG for details Intoduction 🖍 Highlight whatever you want! Highlighter will magically find UI objects such as UILabel,

UILabel drop-in replacement supporting Hashtags
UILabel drop-in replacement supporting Hashtags

ActiveLabel.swift UILabel drop-in replacement supporting Hashtags (#), Mentions (@), URLs (http://), Emails and custom regex patterns, written in Swif

Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.

Atributika is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or

KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.
KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.

KDEDateLabel KDEDateLabel is an UILabel subclass that saves you from refreshing it when using 'time ago' format. Installation You have multiple choice

A morphing UILabel subclass written in Swift.
A morphing UILabel subclass written in Swift.

LTMorphingLabel A morphing UILabel subclass written in Swift. The .Scale effect mimicked Apple's QuickType animation of iOS 8 of WWDC 2014. New morphi

UILabel with image placed from left or right
UILabel with image placed from left or right

SMIconLabel UILabel with possibility to place small icon on the left or on the right side. Take a look at preview image or build sample app to see how

Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.

Atributika is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or

Comments
  • Is there any way to add a NSNumberFormatter?

    Is there any way to add a NSNumberFormatter?

    For example, if I would like to display the numbers with commas in between every thousand: 1,000,000, which we can achieve with NSNumberFormatter.

    Thanks!

    opened by CharlesW95 2
  • Swift Package Manager issue

    Swift Package Manager issue

    Hi, I'd love to use the library via SPM but I get the following error:

    "The package dependency graph can not be resolved; unable find any available tag for the following requirements"

    I tried in a fresh Xcode Project and got the same. Any ideas?

    PS: Congrats on the great library 💯

    opened by s4cha 1
  • Xcode 10 compatibility

    Xcode 10 compatibility

    I replaced the old formatRange initializer inside updateText with the simpler range literal to make this library compatible with Xcode 10 & Swift 4.2.

    opened by slashmo 1
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
Releases(4.0.0)
Owner
Tom Baranes
👋
Tom Baranes
A drop-in replacement for UILabel that supports attributes, data detectors, links, and more

TTTAttributedLabel A drop-in replacement for UILabel that supports attributes, data detectors, links, and more TTTAttributedLabel is a drop-in replace

TTTAttributedLabel 8.8k Dec 30, 2022
UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.

THLabel THLabel is a subclass of UILabel, which additionally allows shadow blur, inner shadow, stroke text and fill gradient. Requirements iOS 4.0 or

Tobias Hagemann 654 Nov 27, 2022
A simple designable subclass on UILabel with extra IBDesignable and Blinking features.

JSLabel Demo pod try JSLabel ...or clone this repo and build and run/test the JSLabel project in Xcode to see JSLabel in action. If you don't have Coc

Jogendra 6 May 9, 2022
Glitching UILabel for iOS 📺

Glitching UILabel for iOS ?? Created by Lee Sun-Hyoup. Try the sample $ pod try GlitchLabel Requirements iOS 8.0+ Swift 3 Xcode 8 Installation CocoaP

Lee Sun-Hyoup 1k Dec 14, 2022
A handy class for iOS to use UILabel as a countdown timer or stopwatch just like in Apple Clock App.

MZTimerLabel Purpose MZTimerLabel is a UILabel subclass, which is a handy way to use UILabel as a countdown timer or stopwatch just like that in Apple

Mines Chan 1.6k Dec 14, 2022
UILabel drop-in replacement supporting Hashtags

ActiveLabel.swift UILabel drop-in replacement supporting Hashtags (#), Mentions (@), URLs (http://), Emails and custom regex patterns, written in Swif

Optonaut 4.2k Dec 31, 2022
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.

Atributika is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or

Pavel Sharanda 1.1k Dec 26, 2022
KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.

KDEDateLabel KDEDateLabel is an UILabel subclass that saves you from refreshing it when using 'time ago' format. Installation You have multiple choice

Kevin Delannoy 117 May 16, 2022
A morphing UILabel subclass written in Swift.

LTMorphingLabel A morphing UILabel subclass written in Swift. The .Scale effect mimicked Apple's QuickType animation of iOS 8 of WWDC 2014. New morphi

Lex Tang 7.9k Jan 4, 2023
UILabel with image placed from left or right

SMIconLabel UILabel with possibility to place small icon on the left or on the right side. Take a look at preview image or build sample app to see how

Anatoliy Voropay 94 Apr 27, 2022