I'm trying to create an animation of a View coming into the screen from the bottom. But in the very first time it only appears on screen without any animation and then it starts work properly.
This is the code:
struct ContentView: View {
@State private var showView = false
var body: some View {
ZStack(alignment: .bottom){
VStack{
Button("TAP HERE") {
withAnimation(.spring()) {
showView.toggle()
}
}
Spacer()
}
if showView {
RoundedRectangle(cornerRadius: 30)
.frame(height: UIScreen.main.bounds.height * 0.5)
.transition(.move(edge: .bottom))
}
}
.edgesIgnoringSafeArea(.bottom)
}
}
This is the behavior:
What I'm doing wrong?
I'm using Xcode 14 beta 5 and Swift 5