struct ContentView: View {
//list 使用方法
@State private var animationAmount: CGFloat = 1
@State var enabled:Bool = false
var body: some View {
ZStack{
Button("Tap Me") {
self.enabled = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
animationAmount = 0.9
self.enabled = false
}
}
.frame(width: 100, height: 100)
.background(Color.blue )
.foregroundColor(.white)
.clipShape(Circle())
.scaleEffect(enabled ? 0.9 : 1.0)
.animation(.interpolatingSpring(stiffness: 300, damping: 10))
.background(
ZStack{
if !enabled {
Circle()
.stroke(Color.blue)
.scaleEffect(animationAmount)
.opacity(Double(1.5 - animationAmount))
.onAppear{
animationAmount = 1.5
}
.animation(.default)
}
}
)
}
}
}
网友评论