Let's say I have a number and I want to animate the transition each time it changes its value. So the value disappears to the left and the new increased value appears from the right. Can this easily be made using .transition(.slide)?
struct ContentView: View {
@StateObject var viewModel = ViewModel()
var body: some View {
VStack(spacing: 64) {
Text(viewModel.count.description)
.font(.largeTitle)
Button("Increment", action: viewModel.increment)
}
}
}
final class ViewModel: ObservableObject {
@Published var count = 0
func increment() {
count += 1
}
}
