A Swift UIView with animated confetti to present success states
- Swift Package Manager (SPM) -
https://github.com/rursache/RSConfettiView
- Copy
RSConfettiView.swift
(fromSources/
) in your project
- One time use
import RSConfettiView
func showConfetti() {
RSConfettiView.showConfetti(inView: UIView, type: .confetti, intensity: Float, duration: Double, confettiBlocksUI: Bool) {
// completition handler
}
}
- Storyboard view / Programatic mode
import RSConfettiView
@IBOutlet private weak var confettiView: RSConfettiView!
func showConfetti() {
self.confettiView.type = .confetti
self.confettiView.intensity = 10 // optional customization
self.confettiView.startConfetti()
}
func hideConfetti() {
self.confettiView.stopConfetti()
}
func confettiIsActive() -> Bool {
return self.confettiView.isActive()
}
You can provide a custom image for the confetti particles using type: .image(UIImage)
at init
RSConfettiView is available under the MPL-2.0 license. See the LICENSE file for more info.