Created
April 30, 2022 19:28
-
-
Save ashishkakkad8/c4760e71fa16af422b85c1bd2dffcd58 to your computer and use it in GitHub Desktop.
SwiftUI Particle View for AKSwiftUIParticles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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