Skip to main content

SwiftUI animation example

SwiftUI Menu Animation: Context Menu Pop-Up

iOS context menus have a distinctive feel: the item you press lifts toward you, everything else blurs and dims, and the menu springs open from the item's corner. This recreates that sequence so you can use it for your own menus or see each part slowed down and adjustable.

  • 4.6 KB file
  • 4 live inputs
  • SwiftUI runtime
Live, try it

How this context menu pop works

  • Pressing for 350 ms commits the menu; a short tap only nudges the card.
  • The card scales to 1.05 while the background darkens; the menu grows from the card's corner on a spring.
  • Choosing an item fires "select" and closes the menu in reverse.

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

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

Inputs

InputTypeDefaultRange
itemsTextReply,Forward,Copy,Pin,Delete—
accentText#0a84ffhex colour
inkText#f5f5f7hex colour
bgText#1c1c1ehex colour

Events: select

More SwiftUI animations

The same idea in other frameworks: React morphing hamburger menu · Flutter 3d drawer menu · Flutter morphing icons