Use the example app to experiment with these different properties
// Create confetti view let confettiView = ConfettiView(frame: self.view.bounds) // Add confetti view as subview self.view.addSubview(confettiView) // Start the confetti 🎉 confettiView.start()
The confetti animation can be started and stopped by calling the
To immediately clear all confetti on stopping, the
clear argument can be given as
To check whether the confetti animation is active, get the
LBConfettiView contains four built-in confetti styles,
.triangle. To use these:
confettiView.style = .confetti confettiView.style = .diamond confettiView.style = .star confettiView.style = .triangle
To use a custom image template for the confetti, use the
confettiView.type = .customImage(UIImage(named: "customImage"))
Set the colors of the confetti with the
colors property. This property has a default value of multiple colors.
confettiView.colors = [UIColor.red, UIColor.green, UIColor.blue]
Two confetti sizes are built-in:
.auto, the default, will use the large scale on iPads and the small scale on other iOS devices.
confettiView.scale = .auto
A manual scale can also be provided as a
confettiView.scale = .custom(0.8)
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
LBConfettiView is available through CocoaPods. To install it, simply add the following line to your Podfile:
LBConfettiView can also be installed manually. Just download and drop the
Sources folder in your project. Alternatively, add
LBConfettiView.xcodeproj to your workspace and embed the framework binary.
Lachlan Bell <[email protected]>
Contributions are welcome, see the CONTRIBUTING for more details.