SwiftUI简单动画效果

struct HomeView: View {
    
    @State var isAnimating = false      //动画标记

     var body: some View {
        View{
                  }.opacity(isAnimating ? 1 : 0)
                   .offset(x: 0, y: isAnimating ? 0 : -100)
                   .animation(Animation.spring().delay(0.1))
                  .animation(Animation.interpolatingSpring(stiffness: 100, damping: 10).delay(1))
    }
  .onAppear
        {
            self.isAnimating.toggle()
        }
}
z1dpw-y1hy2.gif

你可能感兴趣的:(SwiftUI简单动画效果)