Last active
September 21, 2020 05:13
-
-
Save amannayak0007/37173bad88b721ce6a31bf4dae6e7707 to your computer and use it in GitHub Desktop.
Custom Loading Indicator
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 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) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Custom loading indicator In SwiftUI