Last active
May 9, 2024 07:36
-
-
Save benigumocom/3eb09ba7f3048e82f5af89459a3dd673 to your computer and use it in GitHub Desktop.
【SwiftUI】.contentTransition(.symbolEffect(.replace)) 👉 https://android.benigumo.com/20240509/contenttransition/
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 TestSymbolTransition: View { | |
@State private var value = true | |
var body: some View { | |
VStack { | |
Button { | |
value.toggle() | |
} label: { | |
Label("Favorite", systemImage: value ? "heart.fill" : "heart") | |
} | |
Button { | |
value.toggle() | |
} label: { | |
Label("Favorite", systemImage: "heart") | |
.symbolVariant(value ? .fill : .none) | |
} | |
Button { | |
value.toggle() | |
} label: { | |
Label("Favorite", systemImage: "heart") | |
.symbolVariant(value ? .fill : .none) | |
.contentTransition(.symbolEffect(.replace)) | |
} | |
Button { | |
value.toggle() | |
} label: { | |
Label("Favorite", systemImage: "heart") | |
.symbolVariant(value ? .fill : .none) | |
.contentTransition( | |
.symbolEffect(value ? .replace.upUp : .replace.downUp) | |
) | |
} | |
} | |
.buttonBorderShape(.capsule) | |
.buttonStyle(.borderedProminent) | |
.tint(.pink) | |
} | |
} | |
#Preview { | |
BackgroundCheckeredPattern { | |
TestSymbolTransition() | |
} | |
} |
Author
benigumocom
commented
May 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment