跳转至
Structure

LinearProgressViewStyle

A progress view that visually indicates its progress using a horizontal bar.

Declaration

struct LinearProgressViewStyle : ProgressViewStyle

Overview

When initializing a ProgressView with init(value:total:), the DefaultProgressViewStyle will typically display a linear progress view style:

struct ContentView: View {
    var body: some View {
        ProgressView(value: 0.5)
    }
}
A ProgressView displaying a gray loading bar filled halfway left to right by blue, as defined by the ProgressView value being 0.5.

A ProgressView initialized with init(), on the other hand, defaults to a "spinner" style:

struct ContentView: View {
    var body: some View {
        ProgressView()
    }
}
A gif displaying a default gray circular style progress view spinning.

To turn it into a linear progress view, apply this style with the progressViewStyle(_:) modifier:

struct ContentView: View {
    var body: some View {
        ProgressView()
            .progressViewStyle(LinearProgressViewStyle())
    }
}
A linear style progress view, displayed as a gray loading bar.

Availability

iOS 14.0+

macOS 11.0+

tvOS 14.0+

watchOS 7.0+

Topics


Initializer

init() Creates a linear progress view style.

init(tint:) Creates a linear progress view style with a tint color.


Type Alias

Body A view representing the body of a progress view.


Instance Method

makeBody(configuration:) Creates a view representing the body of a progress view.