Skip to main content

SwiftUI animation example

SwiftUI Animated Gradient: Living Mesh Background

A slowly moving mesh gradient is the backdrop of many modern iOS screens. This one is made of large, soft color points that drift on their own orbits and blend into each other, so the gradient never repeats. Touch or hover pulls the nearest color toward the pointer, which makes the background feel alive.

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

How this mesh gradient background works

  • Five color points move on independent Lissajous paths; each is drawn as a large radial gradient.
  • The nearest point is attracted to the pointer with a spring and returns to its orbit when released.
  • Speed and the five colors are inputs, so it can follow your brand palette or the time of day.

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-gradient-animation.exode to your app target (download it below).
struct SwiftuiGradientAnimationView: View {
  @StateObject private var controller = ExodeUIController()
  private let json = (try? String(contentsOf: Bundle.main.url(forResource: "swiftui-gradient-animation", withExtension: "exode")!)) ?? "{}"

  var body: some View {
    ExodeUICanvas(
      artboardJson: json,
      fit: "Layout",
      controller: controller,
      onReady: { }
    )
    .frame(height: 760)
  }
}

Inputs

InputTypeDefaultRange
speedNumber10.1 – 3
titleTextGood evening—
accentText#ff2d55hex colour
accent2Text#5856d6hex colour
accent3Text#ff9500hex colour
bgText#0a0a1ahex colour

More SwiftUI animations

The same idea in other frameworks: React depth parallax scene · React layered wave background · Flutter liquid wave header