All Projects → wibosco → Ghosttypewriter

wibosco / Ghosttypewriter

Licence: mit
👻 A UILabel subclass that adds a typewriting animation effect

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ghosttypewriter

GravityTagCloudView
A tag cloud view with gravity.
Stars: ✭ 22 (-86.16%)
Mutual labels:  uilabel, cocoapod
Zswtappablelabel
UILabel subclass for links which are tappable, long-pressable, 3D Touchable, and VoiceOverable.
Stars: ✭ 148 (-6.92%)
Mutual labels:  uilabel
Dataclass factory
Modern way to convert python dataclasses or other objects to and from more common types like dicts or json-like structures
Stars: ✭ 116 (-27.04%)
Mutual labels:  typing
Switch
💊 An iOS switch control implemented in Swift with full Interface Builder support
Stars: ✭ 132 (-16.98%)
Mutual labels:  storyboard
Xib2storyboard
A tool to convert Xcode .xib to .storyboard files
Stars: ✭ 121 (-23.9%)
Mutual labels:  storyboard
Turingtype
⌨️ Simple human typing effect
Stars: ✭ 137 (-13.84%)
Mutual labels:  typing
Uilabel Copyable
A simple category to add copy functionality to UILabel.
Stars: ✭ 113 (-28.93%)
Mutual labels:  uilabel
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (-4.4%)
Mutual labels:  storyboard
Dckit
Set of iOS controls with useful IBInspectable properties. Written on Swift.
Stars: ✭ 144 (-9.43%)
Mutual labels:  storyboard
Apvalidators
Codeless solution for form validation in iOS!
Stars: ✭ 130 (-18.24%)
Mutual labels:  cocoapod
Aicustomviewcontrollertransition
Easy and tidy way for creating custom UIViewController transitions for iOS
Stars: ✭ 130 (-18.24%)
Mutual labels:  cocoapod
Tt
A terminal based typing test.
Stars: ✭ 125 (-21.38%)
Mutual labels:  typing
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (-13.21%)
Mutual labels:  cocoapod
Typedload
Python library to load dynamically typed data into statically typed data structures
Stars: ✭ 120 (-24.53%)
Mutual labels:  typing
Instantiate
Type-safe and constructor injectable InterfaceBuilder protocols.
Stars: ✭ 149 (-6.29%)
Mutual labels:  storyboard
Downloadbutton
Customizable App Store style download button
Stars: ✭ 1,532 (+863.52%)
Mutual labels:  cocoapod
Typescript Vs Flowtype
Differences between Flowtype and TypeScript -- syntax and usability
Stars: ✭ 1,671 (+950.94%)
Mutual labels:  typing
Pinlayout
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Stars: ✭ 1,870 (+1076.1%)
Mutual labels:  cocoapod
Kwdrawercontroller
Drawer view controller that easy to use!
Stars: ✭ 154 (-3.14%)
Mutual labels:  storyboard
Pscarouselview
A drop-in carousel view. Most of Apps put it in their first screen.
Stars: ✭ 149 (-6.29%)
Mutual labels:  storyboard

Build Status Swift Version License Platform CocoaPods Twitter: @wibosco

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.

Usage

Animated Typing

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.

A TypewriterLabel instance when added as a subview will hide it's content.

Starting

Starting the animation will cause the content of the label to be reveal one character at a time.

How quickly each character is revealed is controlled by setting the typingTimeInterval property.

There are two ways to start an animation: with and without a completion closure.

With a completion closure:

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    titleLabel.startTypewritingAnimation {
        //Implement your completion closure body here...
    }
}

Without a completion closure:

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    titleLabel.startTypewritingAnimation()
}

Stopping

Stopping an animation causes the characters that have been revealed to remain as is and no new characters being revealed.

import GhostTypewriter

@IBAction func stopAnimationButtonPressed(_ sender: Any) {
    titleLabel.stopTypewritingAnimation()
}

Resetting

Resetting an animation causes all characters to be hidden.

import GhostTypewriter

@IBAction func resetAnimationButtonPressed(_ sender: Any) {
    titleLabel.resetTypewritingAnimation()
}

It's important to note that resetting an TypewriterLabel instance does not cause the animation to restart instead you need to call restartAnimationButtonPressed().

Restarting

Restarting an animation causes all characters to be hidden and for the animation to begin from the start again.

There are two ways to start an animation: with and without a completion closure.

Without a completion closure:

import GhostTypewriter

@IBAction func restartAnimationButtonPressed(_ sender: Any) {
    titleLabel.restartTypewritingAnimation()
}

With a completion closure:

import GhostTypewriter

@IBAction func restartAnimationButtonPressed(_ sender: Any) {
    titleLabel.restartTypewritingAnimation {
        //Implement your completion closure body here...
    }
}

Completing

Completing an animation causes all characters to instantly be revealed.

import GhostTypewriter

@IBAction func completeAnimationButtonPressed(_ sender: Any) {
    titleLabel.completeTypewritingAnimation()
}

Animation Options

Style

By default TypewriterLabel reveals the content as it animates however this can be changed to hiding the content by setting the animationStyle property to .hide:

import GhostTypewriter

override func viewDidLoad() {
    super.viewDidLoad()

    titleLabel.animationStyle = .hide
}

animationStyle is defaulted to .reveal

Direction

By default TypewriterLabel animates from character index 0 to n-1 however this can be changed to go from charcter index n-1 to 0 by setting the animationDirection to .backward:

import GhostTypewriter

override func viewDidLoad() {
    super.viewDidLoad()

    titleLabel.animationDirection = .backward
}

animationDirection is defaulted to .forward.

Adjusting Animation Timing

Each character of a TypewriterLabel instance is revealed at a pace set by the typingTimeInterval property.

typingTimeInterval defaults to 0.1 second.

import GhostTypewriter

override func viewDidLoad() {
    super.viewDidLoad()

    titleLabel.typingTimeInterval = 0.3
}

It's important to note that setting/changing typingTimeInterval after an animation has been started, has no affect on the timing of that animation.

Storyboards

As TypewriterLabel is contained in a pod, when using it with storyboards you will need to set the Module field to GhostTypewriter.

Migrating from v1 to v2

Version 2.0.0 of GhostTypewriter contains breaking changes.

  • cancelTypewritingAnimation() now use resetTypewritingAnimation().
  • cancelTypewritingAnimation(clearText: true) now use resetTypewritingAnimation().
  • cancelTypewritingAnimation(clearText: false) now use stopTypewritingAnimation().

Example

GhostTypewriter comes with an example project to provide more details than listed above.

Found an issue?

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].