Skip to content

Instantly share code, notes, and snippets.

@kirsteins
Created February 4, 2021 09:37
Show Gist options
  • Save kirsteins/b58d98baddafce3b2839529d70c666c5 to your computer and use it in GitHub Desktop.
Save kirsteins/b58d98baddafce3b2839529d70c666c5 to your computer and use it in GitHub Desktop.
Transitions in SwiftUI
struct ContentView: View {
@State var flag = false
var body: some View {
VStack(spacing: 0) {
Circle().fill(Color.orange)
if flag {
Circle()
.fill(Color.red)
.transition(.opacity)
.animation(.default)
}
}
.background(Color.black.ignoresSafeArea())
.onTapGesture {
withAnimation {
flag.toggle()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment