Skip to content

Instantly share code, notes, and snippets.

@mattyoung
Created August 20, 2023 17:07
Show Gist options
  • Save mattyoung/f8ad5a7b81bb82d670e612ceb02f3b1d to your computer and use it in GitHub Desktop.
Save mattyoung/f8ad5a7b81bb82d670e612ceb02f3b1d to your computer and use it in GitHub Desktop.
import SwiftUI
struct SensoryFeedback: View {
@State private var count = 0
var body: some View {
VStack {
Text(verbatim: "\(count)")
.font(.largeTitle)
.contentTransition(.numericText(value: Double(count)))
Button("+++++++") {
count += 1
}
.sensoryFeedback(.increase, trigger: count)
}
.animation(.easeIn(duration: 0.1), value: count)
}
}
#Preview {
SensoryFeedback()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment