A UILabel subclass that hides text behind animated bubble particles. Tap to reveal with an explosion effect.
ScreenRecording_05-21-2026.23-29-46_1.mov
dependencies: [
.package(url: "https://github.com/da-hye0/BubbleMaskingLabel.git", from: "1.0.0")
]Or in Xcode: File → Add Package Dependencies → paste the repository URL.
import MaskingLabel
let label = MaskingLabel(textColor: .black)
label.numberOfLines = 0
label.text = "This text is hidden behind bubbles!"
view.addSubview(label)Tap the label to reveal the text.
import MaskingLabel
@State private var isMasked = true
MaskingText(
"Hidden message",
isMasked: $isMasked,
textColor: .label,
font: .systemFont(ofSize: 18)
)
Button("Re-mask") { isMasked = true }label.reveal() // Unmask with animation
label.reveal(animated: false) // Unmask instantly
label.mask() // Re-mask the text
label.onReveal = {
print("Text revealed!")
}let attr = NSAttributedString(string: "Styled text", attributes: [
.font: UIFont.boldSystemFont(ofSize: 18)
])
label.attributedText = attrvar tuning = MaskingLabel.TuningSet()
tuning.bubblesPerCharacter = 1.5
tuning.bubbleExplosionDuration = 0.6
tuning.hapticStyle = .heavy // .light, .medium, .heavy, .rigid, .soft, or nil to disable
tuning.bubbleColor = .systemPink // nil = textColor with 0.6 alpha (default)
tuning.lineSpacing = 2.0
tuning.kern = 0.5
label.tuning = tuning| Parameter | Default | Description |
|---|---|---|
lineSpacing |
1.26 | Line spacing for text rendering and bubble positioning |
kern |
1.0 | Character spacing |
bubblesPerCharacter |
1.0 | Bubbles generated per character |
bubbleBatchInterval |
0.08 | Interval between bubble generation batches |
bubbleStartOffsetXRange |
6 | Horizontal spawn offset from character center |
bubbleStartOffsetYRange |
4 | Vertical spawn offset from character center |
bubbleAnimateMinDuration |
1.0 | Min bubble movement duration |
bubbleAnimateMaxDuration |
1.0 | Max bubble movement duration |
minBubbleDistance |
7 | Min bubble travel distance |
maxBubbleDistance |
12 | Max bubble travel distance |
bubbleStartSize |
1.3 | Bubble initial scale |
bubbleEndSize |
0.3 | Bubble final scale |
bubbleExplosionDistance |
20 | Explosion radial distance |
bubbleExplosionDuration |
0.8 | Explosion animation duration |
hapticStyle |
.medium |
Haptic feedback on tap (nil to disable) |
bubbleColor |
nil |
Bubble color (nil = textColor at 60% opacity) |
cd Example
xcodegen generate
open MaskingLabelExample.xcodeprojRequires XcodeGen.
- iOS 15.0+
- Swift 5.9+
MIT License. See LICENSE for details.