Skip to content

Instantly share code, notes, and snippets.

@kamaravichow
Created March 7, 2022 17:13
Show Gist options
  • Save kamaravichow/d267a6105f41ca6c22beee0ca16cf3ce to your computer and use it in GitHub Desktop.
Save kamaravichow/d267a6105f41ca6c22beee0ca16cf3ce to your computer and use it in GitHub Desktop.
iOS version of gradient circular progress bar SwiftUI
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