I want the second rectangle (green) come up and down over the first rectangle (red) when I press the button
struct ContentView: View {
@State var visible = false
var body: some View {
return HStack {
Button("button") {
self.visible.toggle()
}
ZStack {
Rectangle()
.frame(width: 100, height: 100)
.foregroundColor(Color.red)
if visible {
Rectangle()
.frame(width: 100, height: 100)
.foregroundColor(Color.green)
.transition(.move(edge: .bottom))
.animation(.linear(duration: 2))
}
}
}
}
}
When the green rectangle appears it comes up over the red rectangle, but when it disappears the the moving transition appears behind the red rectangle.
