0% found this document useful (0 votes)
6 views2 pages

Circular Progress View Style

The document describes how to create a `CircularProgressViewStyle` in SwiftUI, allowing customization of a `ProgressView` to appear as a spinner. It includes examples of initializing the style with and without a tint color, as well as how to use `Color` as a view and as a shape style fill or stroke. Additionally, it notes that `Color` is resolved to a concrete value just before being used in the environment.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Circular Progress View Style

The document describes how to create a `CircularProgressViewStyle` in SwiftUI, allowing customization of a `ProgressView` to appear as a spinner. It includes examples of initializing the style with and without a tint color, as well as how to use `Color` as a view and as a shape style fill or stroke. Additionally, it notes that `Color` is resolved to a concrete value just before being used in the environment.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Creates a circular progress view style.

Use this intitializer to create a ``CircularProgressViewStyle``.


This allows you to style a ``ProgressView`` like a spinner,
overriding any default styles:

```
struct ContentView: View {
var body: some View {
ProgressView(value: 0.75)
.progressViewStyle(CircularProgressViewStyle())
}
}
```

![A gif displaying a gray circular style progress view spinning.]


(circularprogressviewstyle-example-1.gif)

- Note: To give the spinner a tint color, use


``CircularProgressViewStyle/init(tint:)``
instead.

Creates a circular progress view style with a tint color.

Use this initializer to create a ``CircularProgressViewStyle``


with a `tint` color:

```
struct ContentView: View {
var body: some View {
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: .orange))
}
}
```

![A gif displaying an orange circular style progress view spinning.](progress-


spinner-orange-ex.gif)

Creates a view representing the body of a progress view.

- Parameter configuration: The properties of the progress view, such as


its preferred progress type.
A view representing the body of a progress view.
An environment-dependent color.

`Color` represents an environment-dependent color that conforms to ``View``.


Colors conformance to ``View`` means that a color can be used as a view
itself.

For example:

struct ExampleView: View {


var body: some View {
Color.yellow
}
}

![A yellow view in which the color conforms to view and hence is
used as a view itself.](color-example-one.png)

`Color` also conforms to ``ShapeStyle`` which allows it to serve as a fill


or stroke on a shape.

For example, as a fill:

struct ExampleView: View {


var body: some View {
Circle()
.fill(Color.yellow)
}
}

![A view containing a large yellow-filled circle in which the color conforms
to ShapeStyle and serves as the fill on the circle shape.](color-example-two.png)

And as a stroke:

struct ExampleView: View {


var body: some View {
Circle()
.stroke(Color.yellow)
}
}

![A view containing a large circle with a yellow outline in which the color
conforms
to ShapeStyle and serves as the stroke on the circle shape.](color-example-
three.png)

- Note: A ``Color`` is a late-binding token: SwiftUI only resolves it to a


concrete
value just before using it in a given environment.

You might also like