DevTechie.com

import SwiftUIstruct CustomProgressView: View {
@Binding var progress: CGFloat
}
}import SwiftUIstruct CustomProgressView: View {
@Binding var progress: CGFloat
var body: some View {
ZStack {
// progress track
Circle()
// progress circle
Circle()
}
.frame(width: 200, height: 200)
.padding()
}
}import SwiftUIstruct CustomProgressView: View {
@Binding var progress: CGFloat
var body: some View {
ZStack {
// placeholder
Circle()
.stroke(lineWidth: 20)
.foregroundColor(.gray)
.opacity(0.2)
// progress circle
Circle()
.trim(from: 0.0, to: min(progress, 1.0))
.stroke(AngularGradient(colors: [.yellow, .orange, .pink, .red], center: .center), style: StrokeStyle(lineWidth: 20, lineCap: .butt, lineJoin: .miter))
}
.frame(width: 200, height: 200)
.padding()
}
}struct CustomProgressView: View {
@Binding var progress: CGFloat
var body: some View {
ZStack {
// placeholder
Circle()
.stroke(lineWidth: 20)
.foregroundColor(.gray)
.opacity(0.2)
// progress circle
Circle()
.trim(from: 0.0, to: min(progress, 1.0))
.stroke(AngularGradient(colors: [.yellow, .orange, .pink, .red], center: .center), style: StrokeStyle(lineWidth: 20, lineCap: .butt, lineJoin: .miter))
.rotationEffect(.degrees(-90))
.shadow(radius: 2)
Text("\(String(format: "%0.0f", progress * 100))%")
.font(.largeTitle)
}
.frame(width: 200, height: 200)
.padding()
.animation(.easeInOut, value: progress)
}
}struct CustomProgressViewUser: View {
@State private var progress: CGFloat = 0.0
var body: some View {
VStack {
CustomProgressView(progress: $progress)
.padding(.bottom, 40)
Slider(value: $progress, in: 0.0...1.0)
}
.padding()
}
}import SwiftUIstruct CustomProgressView: View {
@Binding var progress: CGFloat
var body: some View {
ZStack {
// placeholder
Circle()
.stroke(lineWidth: 20)
.foregroundColor(.gray)
.opacity(0.2)
// progress circle
Circle()
.trim(from: 0.0, to: min(progress, 1.0))
.stroke(AngularGradient(colors: [.yellow, .orange, .pink, .red], center: .center), style: StrokeStyle(lineWidth: 20, lineCap: .butt, lineJoin: .miter))
.rotationEffect(.degrees(-90))
.shadow(radius: 2)
Text("\(String(format: "%0.0f", progress * 100))%")
.font(.largeTitle)
}
.frame(width: 200, height: 200)
.padding()
.animation(.easeInOut, value: progress)
}
}struct CustomProgressViewUser: View {
@State private var progress: CGFloat = 0.0
var body: some View {
VStack {
CustomProgressView(progress: $progress)
.padding(.bottom, 40)
Slider(value: $progress, in: 0.0...1.0)
}
.padding()
}
}struct CustomProgressView_Previews: PreviewProvider {
static var previews: some View {
CustomProgressViewUser()
}
}