This is a SwiftUI package that adds animations to ordinary Text views. When the input string of the AnimatedText changes, your text will come to life and showcase it's change with a character typing animation.

About

This animation utilizes the new onChange() function available in iOS 14.(Documentation Here). When the state changes, the new value is sent through the onChange() function before the value is changed. The Needleman-Wunsch algorithm is then used at this time to calculate which characters have changed in the string and generate the shortest list of modifications we can apply to get the new string. This allows the string to animate smoothly to the next value.

Good examples to try it out on are abbreviations and acronyms along with their full word.

Requirements

  • iOS 14.0+
  • macOS 10.16+

Add Via Swift Package Manager (SPM)

https://github.com/jboullianne/TCAnimatedText.git

Github Link - https://github.com/jboullianne/TCAnimatedText

Usage

// Three Parameters:
// -- String Input
// -- Character Change Duration (seconds)
// -- Modifier Closure to change text style directly
AnimatedText($input, charDuration: 0.07) { text in
    text
        .font(.largeTitle)
        .fontWeight(.bold)
        .foregroundColor(.green)
}

Show us what you made!

We want to see what you've made using this package! Send us pics! Find us on Twitter @TrailingClosure, on Instagram, or email us at [email protected]