Created
September 21, 2020 05:15
-
-
Save amannayak0007/d75ea4cb3c8ebffe65af189898b5d9e5 to your computer and use it in GitHub Desktop.
Circular Progress View
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 : Bool = false | |
var body: some View { | |
ZStack { | |
Color(.black).ignoresSafeArea(.all) | |
Circle() | |
.trim(from: 0, to: 0.37) | |
.stroke(Color.green, lineWidth: 15) | |
.frame(width: 100, height: 100, alignment: .center) | |
.rotationEffect(Angle(degrees: isLoading ? 0 : 360)) | |
Text("Loading..") | |
.foregroundColor(.green) | |
.fontWeight(.bold) | |
.onAppear() { | |
withAnimation(Animation.linear(duration: 1.0).repeatForever(autoreverses: false)) { | |
isLoading.toggle() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Circular Progress View