BertanT/SwiftUIConfettiOverlay
Simple and Customizable SwiftUI Confetti Modifier Package That Lets You Add Confetti to Anything!
π Overview
Simple and Customizable SwiftUI Confetti Modifier Package That Lets You Add Confetti to Anything!
Requires Mac Catalyst 15, iOS/iPadOS 15, tvOS 15, or newer. Built for SwiftUI.
[Static Badge] [Static Badge]
π Usage
Add the .confettiOverlay modifier to any SwiftUI view you want to add confetti over, and that's it! The below example demonstrates how to add confetti to a View and toggle the emission with a Button. A boolean State property controls the emission.
import SwiftUIConfettiOverlay
struct ContentView: View {
// Property controlling emission
@State private var isEmitting = false
var body: some View {
VStack {
Button("Party!") {
// Toggle emission on button press
isEmitting.toggle()
}
}
// Add confetti over this VStack! π
.confettiOverlay(isEmitting: isEmitting)
}
}Customization
.confettiOverlay(amount: Float, colors: [UIColor], isEmitting: Bool)You can also play with these optional parameters and make the confetti your own!
amount:Floatvalue to control how much confetti you want!
* Default: 10
colors:UIColorArrayvalue that specifies the colors of your confetti pieces. Add as many as you wish!
* Default: [.systemYellow, .systemMint, .systemIndigo, .systemPink]
Package Metadata
Repository: BertanT/SwiftUIConfettiOverlay
Stars: 7
Forks: 1
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
README: README.md