A progress view is a view that shows the progress towards completion of a task.
ContentView.swift
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | // // ContentView.swift // swiftuidev // // Created by Cairocoders // import SwiftUI struct ContentView: View { @State private var progress = 0.0 var body: some View { VStack(spacing: 30) { HStack { VStack { ProgressView( "Progress" , value: progress, total: 100) .accentColor(Color.green) .padding([.leading, .trailing], 10) .scaleEffect(x: 1, y: 4, anchor: .center) Button( "Increment Progress" ) { if progress < 100 { progress += 10 } } .padding(.top) .padding() Text( "Current Progress: \(Int(progress))%" ) .padding() } } HStack { VStack { ProgressView() .scaleEffect(1.5, anchor: .center) .progressViewStyle(CircularProgressViewStyle(tint: .blue)) } } } .padding(.all, 10) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |