Posts

Showing posts from November, 2019

A Simple SwiftUI animation

Image
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