Skip to content

Instantly share code, notes, and snippets.

@SarahAlsharif
Last active September 21, 2021 22:52
Show Gist options
  • Save SarahAlsharif/390f41717b17b8278a990d81031a04e8 to your computer and use it in GitHub Desktop.
Save SarahAlsharif/390f41717b17b8278a990d81031a04e8 to your computer and use it in GitHub Desktop.
struct ParticlesModifier: ViewModifier {
@State var time = 0.0
@State var scale = 0.1
let duration = 5.0
func body(content: Content) -> some View {
ZStack {
ForEach(0..<80, id: \.self) { index in
content
.hueRotation(Angle(degrees: time * 80))
.scaleEffect(scale)
.modifier(FireworkParticlesGeometryEffect(time: time))
.opacity(((duration-time) / duration))
}
}
.onAppear {
withAnimation (.easeOut(duration: duration)) {
self.time = duration
self.scale = 1.0
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment