Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Last active May 9, 2021 02:11
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 KentarouKanno/30cdb42bae7afdc73e5c07309ca3404c to your computer and use it in GitHub Desktop.
Save KentarouKanno/30cdb42bae7afdc73e5c07309ca3404c to your computer and use it in GitHub Desktop.
import SwiftUI

struct ContentView: View {
    
    @State var breatheOut = false
    @State var breatheIn = true
    
    var body: some View {
        
        ZStack {
            
            Color.black
                    .edgesIgnoringSafeArea(.all)
            
            Text("Breathe In")
                .foregroundColor(.white)
                .opacity(breatheIn ? 0 : 1)
                .scaleEffect(breatheIn ? 0 : 1, anchor: .center)
                .animation(Animation.easeInOut(duration: 4)
                            .delay(0.75)
                            .repeatForever(autoreverses: true))
                .onAppear {
                    breatheIn.toggle()
                }
            
            Text("Breathe Out")
                .foregroundColor(.white)
                .opacity(breatheOut ? 0 : 1)
                .animation(Animation.easeInOut(duration: 4)
                            .delay(0.75)
                            .repeatForever(autoreverses: true))
                .onAppear {
                    breatheOut.toggle()
                }
                
        }
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

画面収録 2021-05-09 11 05 08 2021-05-09 11_09_04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment