Skip to content

Instantly share code, notes, and snippets.

@amannayak0007
Last active September 21, 2020 05:13
Show Gist options
  • Save amannayak0007/37173bad88b721ce6a31bf4dae6e7707 to your computer and use it in GitHub Desktop.
Save amannayak0007/37173bad88b721ce6a31bf4dae6e7707 to your computer and use it in GitHub Desktop.
Custom Loading Indicator
import SwiftUI
struct ContentView: View {
@State var isLoading = false
var body: some View {
ZStack {
Color(.black)
.edgesIgnoringSafeArea(.all)
Circle()
.stroke(style: StrokeStyle(lineWidth: 8, lineCap: .round, dash: [4, 20]))
.frame(width: 100, height: 100, alignment: .center)
.foregroundColor(.green)
.onAppear() {
withAnimation(Animation.linear(duration: 2.0).repeatForever(autoreverses: false))
{
isLoading.toggle()
}
}
.rotationEffect(Angle(degrees: isLoading ? 0 : 360))
Text("Loading..")
.foregroundColor(.green)
}
}
}
@amannayak0007
Copy link
Author

amannayak0007 commented Sep 21, 2020

Custom loading indicator In SwiftUI

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