Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Created August 17, 2024 11:44
Show Gist options
  • Save benigumocom/06e1baaae40405a0cb06686d9d0dfdfe to your computer and use it in GitHub Desktop.
Save benigumocom/06e1baaae40405a0cb06686d9d0dfdfe to your computer and use it in GitHub Desktop.
【SwiftUI】Basic transition 👉 https://zenn.dev/maochanz/articles/0bcd4bfaa43a0d
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
}
@benigumocom
Copy link
Author

sc 2024-08-17 at 20 22 28w

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment