SkillAgentSearch skills...

SwiftConfettiView

Celebrate every moment in your app. Customizable confetti with presets, haptics, sound. Supports UIKit and SwiftUI.

Install / Use

/learn @ugurethemaydin/SwiftConfettiView
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<p align="center"> <img src="icon.png" alt="SwiftConfettiView" width="128" height="128" style="border-radius: 22%;"> </p> <h1 align="center">SwiftConfettiView</h1> <p align="center"> <a href="https://twitter.com/intent/tweet?text=Celebrate%20every%20moment%20in%20your%20app%20with%20SwiftConfettiView%20🎉&url=https://github.com/ugurethemaydin/SwiftConfettiView&hashtags=swift,ios,swiftui,confetti,opensource"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social" alt="Tweet"></a> </p> <p align="center"><b>Celebrate every moment in your app</b></p> <p align="center"> <img src="https://img.shields.io/badge/Language-%20Swift%20-orange.svg" alt="language"> <img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="CI Status"> <a href="https://cocoapods.org/pods/SwiftConfettiView"><img src="https://img.shields.io/cocoapods/v/SwiftConfettiView.svg?style=flat" alt="Version"></a> <a href="https://cocoapods.org/pods/SwiftConfettiView"><img src="https://img.shields.io/cocoapods/l/SwiftConfettiView.svg?style=flat" alt="License"></a> <a href="https://cocoapods.org/pods/SwiftConfettiView"><img src="https://img.shields.io/cocoapods/p/SwiftConfettiView.svg?style=flat" alt="Platform"></a> </p> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="240" align="center" style="border: none"><img src="demo-list.png" alt="Example app" width="220"><br><b>Example App</b></td> <td style="border: none; vertical-align: top; padding-left: 24px">

Add beautiful confetti animations to your iOS app in just a few lines of code. Built on CAEmitterLayer for smooth, high-performance particle rendering. Supports UIKit and SwiftUI with ready-to-use presets, burst and rain modes, haptic feedback, sound effects, and full customization of colors, shapes, and physics.

iOS 13.0+ · Swift 5.0+

</td> </tr> </table> <table align="center" border="0" cellspacing="0" cellpadding="16"> <tr> <td align="center" style="border: none"><b>Perfect</b><br><video src="https://github.com/user-attachments/assets/92fdc387-a05a-426f-8d03-eb48e53c2f91" width="280" autoplay loop muted playsinline></video></td> <td align="center" style="border: none"><b>Default Rain</b><br><video src="https://github.com/user-attachments/assets/561f6fd0-84f2-4ec4-9689-144aedabb23a" width="280" autoplay loop muted playsinline></video></td> </tr> <tr> <td align="center" style="border: none"><b>From a Point</b><br><video src="https://github.com/user-attachments/assets/1e080fbe-acbd-4bdf-aaef-c17b0dd0d8c0" width="280" autoplay loop muted playsinline></video></td> <td align="center" style="border: none"><b>Firework</b><br><video src="https://github.com/user-attachments/assets/da0c3169-1a86-4450-bcb1-c13878804fd1" width="280" autoplay loop muted playsinline></video></td> </tr> <tr> <td align="center" style="border: none"><b>Emoji</b><br><video src="https://github.com/user-attachments/assets/80f22aa4-c2f6-49cc-90d0-93c7892f796c" width="280" autoplay loop muted playsinline></video></td> <td align="center" style="border: none"><b>SF Symbol</b><br><video src="https://github.com/user-attachments/assets/1728db4e-5ebc-4540-9491-3455a22ab434" width="280" autoplay loop muted playsinline></video></td> </tr> <tr> <td align="center" style="border: none"><b>Custom Colors</b><br><video src="https://github.com/user-attachments/assets/beec1dc8-f716-46f4-bfb6-d392681e248d" width="280" autoplay loop muted playsinline></video></td> <td align="center" style="border: none"><b>Repeat Burst</b><br><video src="https://github.com/user-attachments/assets/29666ae7-57ae-4c55-80ba-e066becab00d" width="280" autoplay loop muted playsinline></video></td> </tr> <tr> <td align="center" style="border: none"><b>Depth Effect</b><br><video src="https://github.com/user-attachments/assets/8e84b83d-8510-4a10-ac0f-c19b79f6f554" width="280" autoplay loop muted playsinline></video></td> <td align="center" style="border: none"><b>UIKit</b><br><video src="https://github.com/user-attachments/assets/1b320105-d588-40c6-b227-47c33cc327d7" width="280" autoplay loop muted playsinline></video></td> </tr> </table>

Installation

Swift Package Manager

Add SwiftConfettiView to your project via Xcode:

  1. File → Add Package Dependencies
  2. Enter the repository URL:
https://github.com/ugurethemaydin/SwiftConfettiView.git

Or add it to your Package.swift:

dependencies: [
    .package(url: "https://github.com/ugurethemaydin/SwiftConfettiView.git", from: "1.0.0")
]

CocoaPods

SwiftConfettiView is also available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SwiftConfettiView'

And then run:

$ pod install

Manual Installation

To manually install SwiftConfettiView, simply add SwiftConfettiView.swift to your project.

Usage

Presets

Get started instantly with pre-configured templates:

| Preset | Effect | |--------|--------| | .perfect | Intense burst with depth, haptic & sound | | .firework | 360° star explosion from center | | .rain | Gentle continuous confetti rain |

UIKit:

confettiView.applyPreset(.perfect)
confettiView.startConfetti()

SwiftUI:

ConfettiView(preset: .perfect, isActive: $showConfetti)

Override specific settings after applying a preset:

// UIKit
confettiView.applyPreset(.perfect)
confettiView.playSound = false

// SwiftUI
ConfettiView(preset: .perfect, isActive: $isActive, playSound: false)

UIKit

Creating a SwiftConfettiView is the same as creating a UIView:

let confettiView = SwiftConfettiView(frame: self.view.bounds)

Don't forget to add the subview!

self.view.addSubview(confettiView)

SwiftUI

import SwiftConfettiView

struct ContentView: View {
    @State private var showConfetti = false

    var body: some View {
        ZStack {
            ConfettiView(type: .confetti, isActive: $showConfetti)

            Button("Celebrate!") {
                showConfetti.toggle()
            }
        }
    }
}

Types

Pick one of the preconfigured types of confetti with the .type property, or create your own by providing a custom image. This property defaults to the .confetti type.

| Type | Code | |------|------| | .confetti | confettiView.type = .confetti | | .triangle | confettiView.type = .triangle | | .star | confettiView.type = .star | | .diamond | confettiView.type = .diamond | | .image | confettiView.type = .image(UIImage(named: "smiley")) | | .text | confettiView.type = .text("🎉") | | .sfSymbol | confettiView.type = .sfSymbol("star.fill") |

Colors

Set the colors of the confetti with the .colors property. This property has a default value of multiple colors.

confettiView.colors = [.red, .green, .blue]

Intensity

The intensity refers to how many particles are generated and how quickly they fall. Set the intensity of the confetti with the .intensity property by passing in a value between 0 and 1. The default intensity is 0.5.

confettiView.intensity = 0.75

Density

Control how many particles fill the screen. Higher values = more particles. Default is 1.0.

confettiView.density = 2.0  // double the particles

Emission Origin

By default, confetti rains from the top edge. Set emitterOrigin to emit from a specific point:

confettiView.emitterOrigin = CGPoint(x: 200, y: 300)

Emission Angle & Spread

Control the direction and cone width of particle emission (in radians):

confettiView.emissionAngle = 3 * .pi / 2  // upward
confettiView.spread = .pi / 4              // narrow cone

For a 360-degree firework effect:

confettiView.spread = 2 * .pi

Burst Mode

For a one-shot burst instead of continuous rain, set burstCount:

confettiView.burstCount = 100

The confetti stops automatically after emitting the specified number of particles.

Haptic Feedback

Trigger haptic feedback when confetti starts:

confettiView.hapticFeedback = true

Sound

Play a built-in celebratory sound when confetti starts:

confettiView.playSound = true

Use a custom sound file:

confettiView.customSoundURL = Bundle.main.url(forResource: "victory", withExtension: "mp3")

Depth Effect

Enable dual-layer parallax for a 3D depth illusion. A background layer (smaller, slower, dimmer particles) is added behind the main foreground layer:

confettiView.addDepth = true

Fade Out

By default, stopping confetti fades out smoothly. Disable for an abrupt stop:

confettiView.fadeOut = false  // default is true

Callback

Get notified when confetti stops:

confettiView.onStop = {
    print("Confetti finished!")
}

Starting / Stopping / Status

confettiView.startConfetti()  // start
confettiView.stopConfetti()   // stop
confettiView.isActive         // true while confetti is on screen

SwiftUI — Advanced Examples

Point emission (burst from a button):

ConfettiView(
    isActive: $isActive,
    emitterOrigin: buttonCenter,
    emissionAngle: 3 * .pi / 2,
    burstCount: 80
)

Firework effect (360-degree burst):

ConfettiView(
    type: .star,
    isActive: $isActive,
    emitterOrigin: CGPoint(x: 200, y: 400),
    spread: 2 * .pi,
    burstCount: 100,
    hapticFeedback: true
)

Emoji confetti:

View on GitHub
GitHub Stars264
CategoryCustomer
Updated16d ago
Forks30

Languages

Swift

Security Score

100/100

Audited on Mar 14, 2026

No findings