A SwiftUI/UIKit library for karaoke-style text highlighting with smooth rounded paragraph backgrounds and precise word tracking. Perfect for reading apps, language learning, text-to-speech interfaces, and text animation effects.
Keywords: iOS text highlight, karaoke text effect, reading progress indicator, smooth text animation, paragraph highlight, word tracking, SwiftUI text effects
- Smooth Rounded Highlights - Seamless paragraph backgrounds with rounded corners across multiple lines
- Karaoke-Style Word Tracking - Precise word-level highlighting following reading progress
- Adaptive Layout - Automatic line wrap and text reflow handling
- Bezier Curve Smoothing - Natural-looking connections using quadratic curves
- Fully Configurable - Customize colors, corner radius, padding, and reading speed
- Performance Optimized - Efficient rendering with NSLayoutManager
![]() |
![]() |
| File | Role |
|---|---|
SmoothHighlightLayoutManager |
Custom NSLayoutManager for rendering smooth paragraph highlights |
SmoothHighlightedTextView |
SwiftUI wrapper for easy integration |
ReadingHighlighter |
Text parser and playback controller with automatic tokenization |
Copy the Highlighting folder into your project:
Highlighting/
├── SmoothHighlightLayoutManager.swift
├── SmoothHighlightedTextView.swift
└── ReadingHighlighter.swift
struct ContentView: View {
@StateObject private var highlighter: ReadingHighlighter
init() {
let text = "Your text content here..."
let attributed = NSAttributedString(string: text)
_highlighter = StateObject(wrappedValue: ReadingHighlighter(
text: text, attributedText: attributed
))
}
var body: some View {
VStack {
SmoothHighlightedTextView(
attributedText: highlighter.attributedText,
paragraphRange: highlighter.currentParagraphRange,
wordRange: highlighter.currentWordRange,
cornerRadius: 6.0,
horizontalPadding: 6.0,
verticalPadding: 2.0
)
HStack {
Button(highlighter.isRunning ? "Pause" : "Play") {
highlighter.isRunning ? highlighter.stop() : highlighter.start()
}
Button("Reset") { highlighter.reset() }
}
}
}
}// Colors
layoutManager.paragraphColor = UIColor(red: 0.74, green: 0.89, blue: 0.76, alpha: 1.0)
layoutManager.wordColor = UIColor(red: 0.20, green: 0.74, blue: 0.42, alpha: 1.0)
// Layout
layoutManager.cornerRadius = 6.0
layoutManager.horizontalPadding = 6.0
layoutManager.verticalPadding = 2.0
// Reading speed (60-600 WPM)
highlighter.updateWordsPerMinute(180)
// Scale highlights with font size
let cornerRadius = fontSize * 0.21
let horizontalPadding = fontSize * 0.21
let verticalPadding = fontSize * 0.07- iOS 15.0+
- Swift 5.9+
- Xcode 15.0+
MIT License - see LICENSE for details.

