Protocol¶
ProgressViewStyle¶
A type that applies standard interaction behavior to all progress views within a view hierarchy.¶
Declaration¶
protocol ProgressViewStyle
Overview¶
Use this protocol to create custom and reusable styles for your ProgressViews.
You can either use a predefined style or create your own style
Predefined Styles¶
There are 3 predefined ProgressView styles in SwiftUI:
- CircularProgressViewStyle - A "spinner" style.
- LinearProgressViewStyle - A loading bar style.
- DefaultProgressViewStyle - The default style based on the context.
To use one of these styles, pass an instance to progressViewStyle(_:):
struct ContentView: View {
var body: some View {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
}
}

Custom Styles¶
To create a custom ProgressViewStyle, create a structure that implements the makeBody(configuration:):
struct DarkBlueShadowProgressViewStyle: ProgressViewStyle {
func makeBody(configuration: Configuration) -> some View {
ProgressView(configuration)
.shadow(color: Color(red: 0, green: 0, blue: 0.6),
radius: 4.0, x: 1.0, y: 2.0)
}
}
struct ShadowedProgressViews: View {
var body: some View {
VStack(spacing: 50) {
ProgressView()
ProgressView(value: 0.75)
}
.progressViewStyle(DarkBlueShadowProgressViewStyle())
}
}

Availability¶
iOS 14.0+
macOS 11.0+
tvOS 14.0+
watchOS 7.0+
Topics¶
Type Alias¶
Configuration A type alias for the properties of a progress view instance.
Instance Method¶
makeBody(configuration:) Creates a view representing the body of a progress view.
Associated Type¶
Body A view representing the body of a progress view.