Skip to content

iOS UILabel with character by character typing /typewriter animation

License

Notifications You must be signed in to change notification settings

dwsdolce/CLTypingLabel

 
 

Repository files navigation

CLTypingLabel Language

A lightweight UILabel subclass with character by character typewriter like animation in Swift, super simple to use

iOS上自带逐字打印动画效果的UILabel

Installation

Manual

  1. Copy and paste CLTypingLabel.swift to your xcode project.
  1. Install the latest release of CocoaPods: gem install cocoapods
  2. Add this line to your Podfile: pod 'CLTypingLabel'
  3. Install the pod: pod install

Usage

  1. Change the class of a label from UILabel to CLTypingLabel;

2. Programmatically set the .text property of your CLTypingLabel to a new String. The animation will be triggered automatically.

Sample Code

@IBOutlet weak var myTypeWriterLabel: CLTypingLabel!

At runtime, set text of the label will trigger animation automatically:

myTypeWriterLabel.text = "This is a demo of typing label animation..."

You can also trigger what you need after animation is finished:

myTypeWriterLabel.onTypingAnimationFinished = {
	//code goes here
}

Also works on attributedText:

myTypeWriterLabel.attributedText = NSAttributedString(string: "This is an attributed text typing animation...", attributes: attr)

You can pause the typing animation at any time:

myTypeWriterLabel.pauseTyping() //this will pause the typing animation
myTypeWriterLabel.continueTyping() //this will continue paused typing animation

And customize time interval between each character:

myTypeWriterLabel.charInterval = 0.08 //optional, default is 0.1

License

This code is distributed under the terms and conditions of the MIT license.

About

iOS UILabel with character by character typing /typewriter animation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 39.7%
  • Objective-C 33.7%
  • Makefile 17.9%
  • Ruby 5.3%
  • C 3.4%