Skip to content

Instantly share code, notes, and snippets.

@ashishkakkad8
Created April 30, 2022 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashishkakkad8/c4760e71fa16af422b85c1bd2dffcd58 to your computer and use it in GitHub Desktop.
Save ashishkakkad8/c4760e71fa16af422b85c1bd2dffcd58 to your computer and use it in GitHub Desktop.
SwiftUI Particle View for AKSwiftUIParticles
//
// AKParticleView.swift
// AKSwiftUIParticles
//
// Created by Ashish Kakkad on 30/04/22.
//
import SwiftUI
import SpriteKit
struct AKParticleView: View {
@State var animatedText: String = ""
@State private var flag = true
var scene: SKScene {
let scene = FirefilesScene()
scene.scaleMode = .resizeFill
scene.backgroundColor = .clear
return scene
}
var body: some View {
ZStack {
SpriteView(scene: scene, options: [.allowsTransparency])
.ignoresSafeArea()
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
VStack() {
Spacer()
Text(animatedText)
.font(.title)
.fontWeight(.light)
.animation(.spring())
.padding()
}
}
.onAppear{
animatedText = ""
"Ashish Kakkad".enumerated().forEach { index, character in
DispatchQueue.main.asyncAfter(deadline: .now() + Double(index) * 0.2) {
animatedText += String(character)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
AKParticleView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment