Created
March 7, 2022 17:13
-
-
Save kamaravichow/d267a6105f41ca6c22beee0ca16cf3ce to your computer and use it in GitHub Desktop.
iOS version of gradient circular progress bar SwiftUI
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
import SwiftUI | |
struct CircularProgressView: View { | |
var progress = 10.0 | |
var body: some View { | |
ZStack { | |
Circle() | |
.stroke(lineWidth: 20) | |
.foregroundColor(.gray) | |
.opacity(0.1) | |
Circle() | |
.trim(from: 0.0, to: min(progress, 1.0)) | |
.stroke( | |
AngularGradient( | |
gradient: Gradient( | |
colors: [.blue, .green, .blue]), | |
center: .center | |
), | |
style: StrokeStyle(lineWidth: 15.0, | |
lineCap: .round, | |
lineJoin: .round)) | |
.rotationEffect((Angle(degrees: 270))) | |
.animation(.easeInOut(duration: 1.0), value: progress) | |
} | |
.frame(width: 250, height: 250) | |
.padding() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment