Enriched Markdown for iOS renders Markdown natively in SwiftUI, including `||spoilers||`. By default they're hidden under a particle field, but you can swap the overlay for your own UIView and decide how hidden text looks and how it reveals itself.
To show what that unlocks, I built a Hogwarts spellbook: every spell in the video is a custom overlay revealing the same Markdown in its own way.
Not every app needs a Patronus, so here's a plain blur. It's one view subclass:
final class BlurOverlayView: SpoilerOverlayView {
private static let context = CIContext()
override func layoutSubviews() {
super.layoutSubviews()
guard let input = CIImage(image: concealedTextImage()) else { return }
layer.contents = Self.context.createCGImage(
input.applyingGaussianBlur(sigma: 6), from: input.extent
)
}
}
struct BlurOverlayProvider: SpoilerOverlayProvider {
func makeOverlay(charRange: NSRange, style: SpoilerStyle) -> SpoilerOverlayView {
let view = BlurOverlayView(charRange: charRange)
view.backgroundColor = style.backgroundColor ?? .systemBackground
return view
}
}
EnrichedMarkdownText(markdown)
.markdownSpoilerOverlay(BlurOverlayProvider())
concealedTextImage() gives you the hidden words laid out exactly where the text view draws them, so you can blur, pixelate, or scramble the real text and nothing jumps on reveal. For your own animation, override animateReveal(completion:).
Installation: https://docs.swmansion.com/enriched-markdown/ios/basics/installation
Docs: https://docs.swmansion.com/enriched-markdown/ios/api-reference/enriched-markdown-text#custom-spoiler-overlays
If it's useful to you, a ⭐ on GitHub helps more people find it: https://github.com/software-mansion/enriched-markdown