Created
December 5, 2025 01:58
-
-
Save amosgyamfi/cf6d3f51c8188169347f8ac2a836007e to your computer and use it in GitHub Desktop.
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
| // | |
| // MovingDashPhase.swift | |
| // | |
| // Created by Amos Gyamfi on 5.12.2025. | |
| // | |
| import SwiftUI | |
| struct MovingDashPhase: View { | |
| var body: some View { | |
| PhaseAnimator([false, true]) { move in | |
| Button { | |
| // | |
| } label: { | |
| ZStack { | |
| Rectangle() | |
| .clipShape(.rect(cornerRadius: 27)) | |
| .frame(width: 160, height: 54) | |
| .foregroundStyle(.indigo.gradient) | |
| RoundedRectangle(cornerRadius: 27) | |
| .stroke( | |
| style: StrokeStyle( | |
| lineWidth: 8, | |
| lineCap: .round, | |
| lineJoin: .round, | |
| dash: [40, 400], | |
| dashPhase: move ? 220 : -220) | |
| ) | |
| .frame(width: 160, height: 54) | |
| .foregroundStyle( | |
| LinearGradient( | |
| gradient: Gradient(colors: [.indigo, .white, .purple, .mint, .white, .orange, .indigo]), startPoint: .trailing, endPoint: .leading) | |
| ) | |
| .shadow(radius: 2) | |
| HStack { | |
| Text("Live Now") | |
| Image(systemName: "arrow.right") | |
| } | |
| .bold() | |
| } | |
| } | |
| .tint(move ? .orange : .white) | |
| .glassEffect() | |
| } animation: { move in | |
| .easeOut.speed(0.1).repeatForever(autoreverses: false) | |
| } | |
| } | |
| } | |
| #Preview { | |
| MovingDashPhase() | |
| .preferredColorScheme(.dark) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment