UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUI Bug?: CircularProgressViewStyle stuck on indeterminate progress

Forums > SwiftUI

Sorry if someone else already posted this. New to this forum and I didn't see a search bar.

I'm following @twostraws tutorials on ProgressView in SwiftUI here and here and my XCode doesn't render the CircularProgressBarStyle correctly. It renders it as a spinning indeterminate ProgressView. (This is supposed to happen if I don't pass in a value to ProgressView() but it's still happening even though I have passed in a value. Here's my code:

ProgressView("Downloading…", value: 4, total: 100)
                .progressViewStyle(CircularProgressViewStyle())

Does anybody else have this behavior? Is it a bug in SwiftUI?

3      

Yes I have the same issue, looks like a bug and I didn't find a workaround yet.

3      

This is the expected behaviour for CircularProgressViewStyle as it a Progress indicator not a Progress status therefore the value and total are not need. In the example How to show progress on a task using ProgressView is using the DefaultProgressViewStyle or LinearProgressViewStyle. If you want the Progress indicator to stop you will need to dismiss the ProgressView.

Using the above HWS example with a CircularProgressViewStyle

struct ContentView: View {
    @State private var downloadAmount = 0.0
    @State private var limitAmount = 50.0
    let timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()

    var body: some View {
        VStack {
            if downloadAmount < limitAmount {
                ProgressView("Downloading…")
                    .progressViewStyle(CircularProgressViewStyle())
            } else {
                Text("Downloaded")
            }

        }
        .onReceive(timer) { _ in
            if downloadAmount < limitAmount {
                downloadAmount += 1
            } 
        }
    }
}

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.