Created
February 25, 2024 10:34
-
-
Save lvjian700/2baeb7d56d55efc86b7b71f7cf65ae87 to your computer and use it in GitHub Desktop.
Showing iMessage like loading 3 dots animation.
This file contains 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 MessageLoadingView: View { | |
@State private var animate = false | |
var body: some View { | |
HStack(spacing: 5) { | |
ForEach(0..<3, id: \.self) { index in | |
Circle() | |
.frame(width: 8, height: 8) | |
.foregroundColor(.gray) | |
.scaleEffect(animate ? 1 : 0.5) | |
.animation( | |
Animation.linear(duration: 0.6) | |
.repeatForever(autoreverses: true) | |
.delay(0.2 * Double(index)) | |
, value: animate | |
) | |
} | |
} | |
.onAppear { | |
animate = true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment