Skip to main content

SwiftUI animation example

SwiftUI Parallax: Tilting Poster With Depth Layers

Apple TV's focus effect turns flat artwork into a little 3D object: as you move, the poster tilts and its layers slide past each other, with a highlight following the light. This card does the same with four layers, a background, a planet, a title and a foreground ring, each at its own depth.

  • 4.3 KB file
  • 5 live inputs
  • SwiftUI runtime
Live, try it

How this tilt parallax poster works

  • Tilt is a spring toward the pointer's offset from the card centre; the card is skewed to fake perspective.
  • Each layer moves by tilt × its depth, so near layers travel farther than the background.
  • A glare gradient sits on top and moves opposite to the tilt, like light reflecting off glass.

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

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

Inputs

InputTypeDefaultRange
depthNumber10 – 2
titleTextORBIT—
accentText#f59e0bhex colour
accent2Text#7c3aedhex colour
bgText#09090bhex colour

More SwiftUI animations

The same idea in other frameworks: React depth parallax scene · Flutter parallax scroll list · Vue starfield parallax hero