ConfettiWithSpriteView
A SwiftUI confetti modifier created by SpriteKit. Easily to use and custom in SwiftUI.
Preview
Installation
In Xcode go to File -> Swift Packages -> Add Package Dependency
and paste in the repo's url:
https://github.com/VIkill33/ConfettiWithSpriteView.git
Or you can download the code of this repo, then Add Local...
in Xcode, and open the folder of the repo.
Usage
- Import this package after you installed by
import ConfettiWithSpriteKit
- Use the modifier like(check it out in DemoAPP inside this package)
When you change the passed var startConfetti
to true
, confetti will play above your modified view(confetti will NOT handle touch events and will pass them to views underit), and false
will stop emitting more confetti.
The var need to be changed to false
then true
to retrigger the confetti.
Parameters
You can custom colors and images of confetti.
All descriptions about parameters were written in comment in source code:
How does it work
It use SKEmitterNode
in SpriteKit to emit particles, which are ribbons in this package defaultly. Particles of SKEmitterNode
behave similarly to CAEmitterLayer
's. This repo is also an example about how to create SKEmitterNodes programmaticaly.