Skip to content

Instantly share code, notes, and snippets.

@ryanlintott
Created June 14, 2025 20:44
Show Gist options
  • Select an option

  • Save ryanlintott/00123bb8cf4a1863c4b8c6b2b8900884 to your computer and use it in GitHub Desktop.

Select an option

Save ryanlintott/00123bb8cf4a1863c4b8c6b2b8900884 to your computer and use it in GitHub Desktop.
A simple heart animation using alignment guides to wipe on and off.
import SwiftUI
struct ContentView: View {
@State private var isOn = false
var body: some View {
VStack {
Image(systemName: "heart")
.overlay {
Image(systemName: "heart.fill")
.mask(alignment: .bottom) {
Circle()
.scale(isOn ? 1.2 : 1)
.alignmentGuide(.bottom) { d in
isOn ? d[.bottom] : d[.top]
}
.alignmentGuide(.leading) { d in
isOn ? d[.leading] : d[.trailing]
}
}
}
.symbolEffect(.bounce.down, value: isOn)
.onTapGesture {
isOn.toggle()
}
.foregroundStyle(.red)
}
.animation(.default, value: isOn)
.font(.largeTitle)
.padding()
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment