Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaskingLabel

A UILabel subclass that hides text behind animated bubble particles. Tap to reveal with an explosion effect.

iOS 15+ Swift 5.9+ SPM

Demo

ScreenRecording_05-21-2026.23-29-46_1.mov

Installation

Swift Package Manager

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.

Usage

UIKit

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.

SwiftUI

import MaskingLabel

@State private var isMasked = true

MaskingText(
    "Hidden message",
    isMasked: $isMasked,
    textColor: .label,
    font: .systemFont(ofSize: 18)
)

Button("Re-mask") { isMasked = true }

Programmatic Control (UIKit)

label.reveal()                  // Unmask with animation
label.reveal(animated: false)   // Unmask instantly
label.mask()                    // Re-mask the text

label.onReveal = {
    print("Text revealed!")
}

AttributedString Support

let attr = NSAttributedString(string: "Styled text", attributes: [
    .font: UIFont.boldSystemFont(ofSize: 18)
])
label.attributedText = attr

Customization

var 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)

Running the Example

cd Example
xcodegen generate
open MaskingLabelExample.xcodeproj

Requires XcodeGen.

Requirements

  • iOS 15.0+
  • Swift 5.9+

License

MIT License. See LICENSE for details.

About

🫧 Interactive UILabel with a bubble-pop reveal effect.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages