Created
August 17, 2024 11:44
-
-
Save benigumocom/06e1baaae40405a0cb06686d9d0dfdfe to your computer and use it in GitHub Desktop.
【SwiftUI】Basic transition 👉 https://zenn.dev/maochanz/articles/0bcd4bfaa43a0d
This file contains hidden or 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
import SwiftUI | |
struct TestTransition: View { | |
@State private var active = false | |
var body: some View { | |
VStack { | |
if active { | |
Image(systemName: "face.smiling") | |
.font(.system(size: 100)) | |
.transition(.slide) | |
Image(systemName: "face.smiling") | |
.font(.system(size: 100)) | |
.transition(.opacity) | |
Image(systemName: "face.smiling") | |
.font(.system(size: 100)) | |
.transition(.scale) | |
Image(systemName: "face.smiling") | |
.font(.system(size: 100)) | |
.transition(.slide.combined(with: .scale)) | |
Image(systemName: "face.smiling") | |
.font(.system(size: 100)) | |
.transition(.asymmetric(insertion: .slide, removal: .scale)) | |
} | |
Button(active ? "hide" : "show") { | |
withAnimation { | |
active.toggle() | |
} | |
} | |
.buttonStyle(.borderedProminent) | |
} | |
} | |
} | |
#Preview { | |
TestTransition() | |
#if os(macOS) | |
.frame(width: 300, height: 600) | |
#endif | |
} |
Author
benigumocom
commented
Aug 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment