Skip to main content

SwiftUI animation example

SwiftUI Loading Animation: Activity Rings Loader

ProgressView gives you a system spinner; this gives your app a loader with personality. Three concentric rings sweep at different speeds with rounded caps and a soft glow, the way Apple's Activity rings look. When the done input flips to true, every ring closes to a full circle and a checkmark draws in the middle.

  • 4.1 KB file
  • 6 live inputs
  • SwiftUI runtime
Live, try it

How this activity rings loader works

  • Each ring's head and tail move at different rates, so its length breathes while it spins.
  • Setting done to true eases every ring to a full circle, then draws the checkmark in 250 ms.
  • A "finished" event fires once the checkmark completes.

Add it to your SwiftUI app

Install ExodeUI (Swift Package), download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import SwiftUI
import ExodeUI

// Add swiftui-loader.exode to your app target (download it below).
struct SwiftuiLoaderView: View {
  @StateObject private var controller = ExodeUIController()
  private let json = (try? String(contentsOf: Bundle.main.url(forResource: "swiftui-loader", withExtension: "exode")!)) ?? "{}"

  var body: some View {
    ExodeUICanvas(
      artboardJson: json,
      fit: "Layout",
      controller: controller,
      onReady: { },
      onTrigger: { name, _ in
        // fires: 'finished'
      }
    )
    .frame(height: 520)
  }
}

Inputs

InputTypeDefaultRange
doneBooleanfalse—
speedNumber10.3 – 3
accentText#fa114fhex colour
accent2Text#92e82ahex colour
accent3Text#1eeaefhex colour
bgText#000000hex colour

Events: finished

More SwiftUI animations

The same idea in other frameworks: React orbit loader · Flutter bouncing bars loader · JavaScript segmented ring spinner