Created
May 30, 2022 16:24
-
-
Save mishimay/ff8769f873d87cc64e234500b0a60efd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var isShrinked = false | |
@State var response: CGFloat = 1 | |
@State var dampingFraction: CGFloat = 0.5 | |
@State var blendDuration: CGFloat = 0 | |
var body: some View { | |
VStack { | |
Circle() | |
.padding(50) | |
.foregroundColor(.purple) | |
.scaleEffect(isShrinked ? 0.5 : 1) | |
.animation(.spring(response: response, dampingFraction: dampingFraction, blendDuration: blendDuration), value: isShrinked) | |
Text("response: " + response.description) | |
Slider(value: $response, in: 0...2) | |
Text("dampingFraction: " + dampingFraction.description) | |
Slider(value: $dampingFraction, in: 0...2) | |
Text("blendDuration: " + blendDuration.description) | |
Slider(value: $blendDuration, in: 0...5) | |
Button("Animate") { | |
withAnimation { | |
isShrinked.toggle() | |
} | |
} | |
} | |
.padding() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment