Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created August 8, 2022 22:26
Show Gist options
  • Select an option

  • Save sturdysturge/0d5bc760c9208543928bd283d8dc0026 to your computer and use it in GitHub Desktop.

Select an option

Save sturdysturge/0d5bc760c9208543928bd283d8dc0026 to your computer and use it in GitHub Desktop.
import SwiftUI
@available(iOS 16.0, *)
struct ContentView: View {
@State var index = 0
@State var edge = Edge.leading
var body: some View {
VStack {
Text("Index \(index)")
.id(index)
.transition(.push(from: edge))
Picker("", selection: $edge) {
ForEach(Edge.allCases, id: \.self) { edge in
Text(edge.name)
}
}
Stepper("") {
withAnimation {
index += 1
}
} onDecrement: {
withAnimation {
index -= 1
}
}
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment