I have taken three seconds to create a countdown UILabel with morphing animation, and some useful function.

The “animate incrementing number in uilabel” is a simple countdown UILabel with morphing animation. The label also has some useful functions to help you get started.


Simple countdown UILabel with morphing animation and a few handy features.



  • a straightforward construction
  • Delegate and easily obtain the state of the countdown from the property.
  • Fill in some of the blanks with function and completeness.
  • As is customary with UILabel, the style changes.
  • LTMorphingLabel’s morphing animation.
  • The assertion of XCTest

Version in Swift vs. version.

A table reveals the version of what you should use for your Swift version is shown below.

Swift version version
4.2 >= 4.0
4.0, 4.1 >= 3.0
3.X >= 2.0
2.3 1.3


Only two lines are required.

/ after 30 minutes, from the current date allow the countdown to begin CountdownLabel CountdownLabel CountdownLabel CountdownLabel (frame: frame, minutes: 30) NSDate and countdownLabel are both valid options. start()

Example of morphing

Make use of animationType. LTMorphingLabel is responsible for this effect.

allow the countdown to begin CountdownLabel(frame: CGRectZero, time: 60*60) Label = CountdownLabel(frame: CGRectZero, time: 60*60) .Pixelate countdownLabel.animationType = countdownLabel.animationType = countdownLabel.animationType = countdownLabel.animationType = count Label.start()


You may use it as a UILabel property exactly like any other.

countdownLabel.text .orange as a color Color() countdown UIFont(name:”Courier”, size:UIFont.labelFontSize()); Label.font = UIFont(name:”Courier”, size:UIFont.labelFontSize()); countdownLabel.start()


Get the current status of the timer

There is a reading status attribute.

countdownLabel.timeCounted = countdownLabel.timeCounted countdownLabel.timeRemaining / how much time is left on the clock @IBAction func @IBAction func @IBAction func @IBAction getTimerCounted is a function that returns the number of times a time (sender: UIButton) debugPrint(“(countdownLabel.timeCounted)”) debugPrint(“(countdownLabel.timeCounted)”) debugPrint(“(countdownLabel.timeCounted func @IBAction @IBAction @IBAction @IBAction @ returnTimerRemaining (sender: UIButton) debugPrint(“(countdownLabel.timeRemaining)”) debugPrint(“(countdownLabel.timeRemaining)”) debugPrint(“(countdownLabel.timeRemaining


Control the timer.

You have the ability to stop, start, and alter the time.

If countdownLabel.isPaused is true, then the countdown is paused. / Start the countdown timer countdownLabel.pause() if countdownLabel.pause() if countdownLabel.pause() if countdownLabel.pause() if countdownLabel.pause() if countdownLabel.pause()

/ -2 minutes for @IBAction func minus(btn: UIButton) countdownLabel.addTime(-2) func minus(btn: UIButton) func minus(btn: UIButton) func minus(btn: UIButton) func minus(btn @IBAction func plus(btn: UIButton) countdownLabel.addTime(2) / +2 minutes for finishing @IBAction


Insertion Method

You may place your function wherever you like by using the function or delegate.

Then the property countdown begins. Label.then(10) in self.countdown, [unowned self] self.countdown.animationType =.Pixelate Label.animationType =.Pixelate .greenColor().textColor().textColor().textColor().textColor().textColor countdown Label.then(5) in self.countdown, [unowned self] self.countdown.animationType =.Sparkle Label.animationType =.Sparkle .yellowColor().textColor().textColor().textColor().textColor().textColor() countdown Label.start() .whiteColor(), self.countdownLabel.textColor =.whiteColor(), self.countdownLabel.textColor =.whiteColor(), self.countdownLabel / assign responsibilities counting func At the (timeCounted timeCounted: NSTimeInterval, timeRemaining: NSTimeInterval) timeRemaining switch { self.countdown is the tenth case. self.countdown.animationType =.Pixelate Label6.animationType =.Pixelate .greenColor = Label6.textColor () self.countdown (case 5) self.countdown Label6.animationType =.Sparkle default: break Label6.textColor =.yellowColor() self.countdownLabel.textColor =.whiteColor() func countdownFinished()


Text With Attribution

You may also set it as attributedText. The morphing animation, however, will be deactivated.

countdown Label.setCountDownTime(30) countdown Label.time “ss” as a format countdown Label.countdown Countdown = AttributedText TextWithAttribution (text: “timer HERE in text”, replacement: “HERE”) countdown Label.start()



If you provide more than 24 hours, the format will be incorrect. Countdown The default format for labels is 00:00:00 (HH:mm:ss). If you’d rather use a different time format, you may do so as shown below.

countdownLabel.time @”mm:ss” format


You may set a timer for a certain period of time.

/ After 10 minutes, a countdown will begin from 20. if fromDate = NSDate; if fromDate = NSDate; if from (). Let targetDate = fromDate using dateByAddingTimeInterval(10). Let’s countdown using dateByAddingTimeInterval(20). Countdown = Label countdownLabel.start(frame: CGRectZero, fromDate: fromDate, targetDate: targetDate) ()

Examine the Situation

There are certain public assets that are beneficial.

countdown Label.is Counting / the timer is now counting down isPaused(); / check whether the countdown timer has been paused Label.is Check to see whether the countdown timer has finished. Check whether morphing is enabled using Label.morphingEnabled.



####CocoaPods is a website where you can find CocoaPods. Simply copy and paste the following into your project’s Podfile:

use frameworks pod ‘CountdownLabel’!

####Carthage Specify Carthage in your Cartfile to incorporate it into your Xcode project:

“suzuki-0000/CountdownLabel” on github



The MIT license applies to this work. For further information, see the LICENSE file.



The “efcountinglabel” is a UILabel that has a morphing animation and some useful functions. It can be used to countdown time, or count up from 0.

Related Tags

  • ltmorphinglabel
  • swiftytimer
  • timer label swift github
  • dwanimatedlabel
  • swift timer label

Comments are closed.