Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created October 8, 2021 14:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chriseidhof/204fec7bc24b69236166a28378a33f92 to your computer and use it in GitHub Desktop.
Save chriseidhof/204fec7bc24b69236166a28378a33f92 to your computer and use it in GitHub Desktop.
ZStack
import SwiftUI
struct ContentView: View {
@State var cond = false
var body: some View {
ZStack {
Color.blue
Test(cond: cond).onTapGesture {
withAnimation(.easeInOut(duration: 2)) {
cond.toggle()
}
}
}
}
}
struct Test: View {
var cond: Bool
var body: some View {
if cond {
Text("One")
} else {
Text("Two")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment