Created
February 4, 2021 09:37
-
-
Save kirsteins/b58d98baddafce3b2839529d70c666c5 to your computer and use it in GitHub Desktop.
Transitions in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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