Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI - ProgressBar inside Live Activity

I am trying to add a simple visual progress bar to my live activity on lock screen or in Dynamic Island but I can't find a way to trigger progress calculation update. Seems like neither Timer nor @State work inside of the live activity. It's weird because both native and public apps do use progress bars in activities that update more often than once a second even when apps are suspended and look super smooth.

Apple native timer app still animates smoothly when suspended

enter image description here

One of my favorite apps - Structured also managed to do it when suspended enter image description here

I tried already even adding Lottie animations to the activity :D

Am I missing something?

like image 984
John Doe Avatar asked Jul 18 '26 05:07

John Doe


1 Answers

Apparently you are not allowed to make custom progress bars in the live activity or at least I didn't find a way to do so. iOS is limiting your abilities to trigger timers, loops and any logical methods to update the progress bar. The only way I found doing it is by using a native progress bar

ProgressView(
    timerInterval: countFrom...endDate,
    countsDown: false,
    label: { EmptyView() },
    currentValueLabel: { EmptyView() }
)
.progressViewStyle(.circular)
like image 94
John Doe Avatar answered Jul 19 '26 20:07

John Doe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!