SwiftUI module that extends the Text class providing a vintage typewriter effect.
Report Bug
·
Request Feature
Welcome to the TypewrittenText SwiftUI module!
In the past, before voice acting was widely used, text in video games would appear on the screen as if it was being typed out. This added a sense of realism to the dialogue, as it mimicked the natural pace of speech by revealing the words gradually.
Nowadays, this technique is still used in some contexts. For instance, ChatGPT from OpenAI uses type-on text to give the impression of spoken conversation when no actual voice is present.
This Swift Package, built entirely with SwiftUI, is a great way to implement the effect on your iOS projects.
- Use all the SwiftUI Text class modifiers, as this module is built on top of it
- Set up the delay between letters to customize the final result
- iOS 13.0 or later
- macOS 10.15 or later
- watchOS 6.0 or later
To install the Kit using Swift Package Manager, you can follow the steps below:
- In Xcode, select
File
→Add Packages...
- Paste https://github.com/hues0s/TypewrittenText inside the search box
Once you have installed the Swift Package, you will need to import it:
import TypewrittenText
And then use the TypewrittenText
class initializer, whose parameters are:
TypewrittenText(finalText: String, delay: Double)
finalText
→ The text you want to typedelay
→ The amount of seconds the app will take before writing the next letter
The following example shows the code used in the demonstration of the module, where the text is written with a delay of 0.2 seconds:
import SwiftUI
import TypewrittenText
struct ContentView: View {
var body: some View {
TypewrittenText(finalText: "Welcome, thank you for watching this demo.", delay: 0.2)
.font(.title)
.padding()
}
}
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
See the open issues for a full list of proposed features (and known issues). If you have a suggestion that would make this better, please:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is distributed under the GNU General Public License. See the LICENSE file for more information.