Activity indicator in Swiftui

Asked

Viewed 21 times

1

How do I display an activity indicator using Swiftui?

I have a vague idea how to do this by introducing the UIActivityIndicatorView of UIKit using the function .overlay(overlay: ) but I wonder if you can do the same using only Swiftui.

1 answer

1


A new view called ProgressView was introduced with iOS 14 (Xcode 12) and can be used to indicate progress indefinitely if it is not used with values for the current state and total.

The default value for the style of ProgressView is CircularProgressViewStyle and corresponds to something very similar to UIActivityIndicatorView of UIKit.

var body: some View {
    VStack {
        ProgressView()
           // caso queira mudar o estilo:
           // .progressViewStyle(CircularProgressViewStyle())
    }
}

More information here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.