跳转至
Structure

DefaultProgressViewStyle

The default progress view style in the current context of the view being styled.

Declaration

struct DefaultProgressViewStyle : ProgressViewStyle

Overview

Use this style to specify the default style for a ProgressView. The style depends on the type of progress view that is being initialized. For example:

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

In this instance, the style displays a spinner. However, if we initialize the ProgressView using init(value:total:) instead, we get a different look:

struct ContentView: View {
    var body: some View {
        ProgressView(value: 5, total: 10)
            .progressViewStyle(DefaultProgressViewStyle())
    }
}
A screenshot of a view displaying a gray progress bar in the center of the screen, spanning the width of the screen with empty space on either side. The progress bar is at half capacity, denoted by a blue fill from the left side to the center.

  • Note: This style does not need to be specified explicitly unless you would like to override a style from higher up in the view hierarchy. This style is used if no others are specified.

Availability

iOS 14.0+

macOS 11.0+

tvOS 14.0+

watchOS 7.0+

Topics


Instance Method

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


Initializer

init() Creates a default progress view style.


Type Alias

Body A view representing the body of a progress view.