Skip to content

Instantly share code, notes, and snippets.

@aheze
Created July 4, 2020 23:17
Show Gist options
  • Select an option

  • Save aheze/cbffa0ed031799201e1722fab5e60df3 to your computer and use it in GitHub Desktop.

Select an option

Save aheze/cbffa0ed031799201e1722fab5e60df3 to your computer and use it in GitHub Desktop.
Text("Press to accelerate!")
.foregroundColor(Color.white)
.padding(10)
.background(Color.gray)
.cornerRadius(6)
.padding(10)
.modifier(TouchDownUpEventModifier(changeState: { (buttonState) in
if buttonState == .pressed {
buttonPressed = true
} else {
buttonPressed = false
}
}))
/// ↓ add this ↓
.scaleEffect(buttonPressed ? 0.9 : 1).animation(.easeOut(duration: 0.2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment