A UILabel
subclass that adds a typewriting animation effect - as if a ๐ป was typing it directly on your user's device!
This pod was inspired by the following post here.
Installation via CocoaPods
To integrate GhostTypewriter
into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
pod 'GhostTypewriter'
Then, run the following command:
$ pod install
CocoaPods 1.1.1+ is required to build
GhostTypewriter
.
TypewriterLabel
is a subclass of UILabel
and where the animation (magic) happens. It works by taking advantage of the attributedText
property on the label and changing the properties of the text content to gradually expose the text using an animation similar to what you get on a mechanical typewriter.
import GhostTypewriter
@IBAction func startAnimationButtonPressed(_ sender: Any) {
descriptionLabel.startTypewritingAnimation(completion: nil)
}
import GhostTypewriter
@IBAction func startAnimationButtonPressed(_ sender: Any) {
if animating {
descriptionLabel.stopTypewritingAnimation()
} else {
descriptionLabel.startTypewritingAnimation(completion: nil)
}
}
import GhostTypewriter
@IBAction func startAnimationButtonPressed(_ sender: Any) {
if animating {
descriptionLabel.cancelTypewritingAnimation()
} else {
descriptionLabel.startTypewritingAnimation(completion: nil)
}
}
import GhostTypewriter
@IBAction func startAnimationButtonPressed(_ sender: Any) {
titleLabel.cancelTypewritingAnimation()
descriptionLabel.cancelTypewritingAnimation()
titleLabel.startGhostTypewriterAnimation {
self.descriptionLabel.startTypewritingAnimation(completion: nil)
}
}
import GhostTypewriter
override func viewDidLoad() {
super.viewDidLoad()
titleLabel.typingTimeInterval = 0.3
}
As TypewriterLabel
contained in a pod, when using it in your storyboards you will need to use the Module
field with the value GhostTypewriter
.
GhostTypewriter
comes with an example project to provide more details than listed above.
Please open a new Issue here if you run into a problem specific to GhostTypewriterLabel, have a feature request, or want to share a comment.
Pull requests are encouraged and greatly appreciated! Please try to maintain consistency with the existing code style. If you're considering taking on significant changes or additions to the project, please communicate in advance by opening a new Issue. This allows everyone to get onboard with upcoming changes, ensures that changes align with the project's design philosophy, and avoids duplicated work.