Library / Press & hold

Long press activation (context menu feel)

Holding an element until a context menu or secondary mode activates — the system "pop".

0ms 100ms 200ms 300ms 400ms
Feel
Silence while holding, then one medium pop exactly when the press is recognized.
APIs
.sensoryFeedback(.impact)UILongPressGestureRecognizer
Minimum OS
iOS 17+ / iOS 10+
Raw .md
SwiftUI (iOS 17+)
import SwiftUI

struct HoldableCard: View {
    @State private var activated = 0

    var body: some View {
        RoundedRectangle(cornerRadius: 16)
            .fill(.quaternary)
            .frame(height: 120)
            .onLongPressGesture(minimumDuration: 0.4) {
                activated += 1
                // show your menu / enter edit mode here
            }
            // "Pop" the instant the long press is recognized
            .sensoryFeedback(.impact(weight: .medium), trigger: activated)
    }
}

// Note: contextMenu {} plays the system pop automatically —
// only add a manual haptic for custom long-press behaviors.
UIKit
let haptic = UIImpactFeedbackGenerator(style: .medium)

let longPress = UILongPressGestureRecognizer(target: self,
                                             action: #selector(handleHold(_:)))
longPress.minimumPressDuration = 0.4
cardView.addGestureRecognizer(longPress)

@objc func handleHold(_ gr: UILongPressGestureRecognizer) {
    switch gr.state {
    case .possible:
        haptic.prepare()
    case .began:
        haptic.impactOccurred() // recognition moment
        // enter edit mode / show menu
    default:
        break
    }
}
Copied