Created
February 4, 2021 09:26
-
-
Save kirsteins/2d77a7aabd69e6fc7ddc09adf2fdaaca to your computer and use it in GitHub Desktop.
Transition 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