Swiftui View verschwindet nicht sofort, nachdem die Übergangsanimation endetIOS

Programmierung für iOS
Anonymous
 Swiftui View verschwindet nicht sofort, nachdem die Übergangsanimation endet

Post by Anonymous »

Ich habe eine Anwendung mit Move Transition erstellt, die eine Ansicht von unten mit Swiftui sendet. Wenn die Ansicht jedoch verschwindet, ist die Übergangsanimation vorbei, aber die Ansicht bleibt ungefähr 1 Sekunden lang. < /P>
Dies ist mein Code.

Code: Select all

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)
}

// This condition sends up the View
if animation {
SecondView()
.transition(.move(edge: .bottom))
}
}
.padding()
}
}

struct SecondView: View {
var body: some View {
VStack {
Text("Hello, world!")
.font(.largeTitle)
.fontWeight(.bold)
Spacer()
}
}
}
Und dies geschah.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post