I had a similar issue and I finally found a solution that worked for me, try wrapping the view in a ZStack and utilizing a .clipped modifier like the below code.
```
struct ContentView: View {
@State var animation: Bool = false
var body: some View {
VStack {
// This is the Button
Button(action: {
withAnimation(.spring(dampingFraction: 1, blendDuration: 0.5)) {
animation.toggle()
}
}) {
Image(systemName: "star.fill")
.resizable()
.frame(width: 100, height: 100)
.foregroundColor(.accentColor)
}
ZStack{
// This condition sends up the View
if animation {
SecondView()
.transition(.move(edge: .bottom))
}
}.clipped()
}
.padding()
}
}
```
Your code is fine (besides the fact that you need a `VStack` wrapping the text and the button), you only need to tell SwiftUI to use the transition by wrapping the command inside `withAnimation()`.
Here's what you simply need to do in ContentView (look at the Button):
```
@ObservedObject var viewModel = ViewModel()
var body: some View {
VStack {
if self.viewModel.model.show {
Text("Showing")
.padding()
} else {
Text("Not Showing")
.padding()
.transition(.asymmetric(insertion: .scale, removal: .opacity))
}
Button {
withAnimation { // This is what you need to trigger the transition
self.viewModel.show()
}
} label: {
Text("Tap to change")
}
}
.animation(.easeIn, value: self.viewModel.show)
}
```