A Simple SwiftUI animation

struct ContentView: View {
   
    @State private var animationAmount: CGFloat = 1
   
   
    var body: some View {
        Button("Tap Me") {
        }
        .padding(40)
        .background(Color.red)
        .foregroundColor(Color.white)
        .clipShape(Circle())
        .overlay(
            Circle()
                .stroke(Color.red)
                .scaleEffect(animationAmount)
                .opacity(Double(2 - animationAmount))
                .animation(
                    Animation.easeOut(duration: 1)
                    .repeatForever(autoreverses: false)
            )
        )
        .onAppear {
                self.animationAmount = 2
        }
    }
}





Credits: https://www.hackingwithswift.com/books/ios-swiftui/customizing-animations-in-swiftui

Comments

Popular posts from this blog

What happened to the blog ?

Why I love to be a programmer ?