<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onLongPressGesture(minimumDuration:maximumDistance:perform:onPressingChanged:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18onLongPressGesture15minimumDuration15maximumDistance7perform0D15PressingChangedQrSd_14CoreFoundation7CGFloatVyycySbcSgtF"
  },
  "title" : "onLongPressGesture(minimumDuration:maximumDistance:perform:onPressingChanged:)"
}
-->

# onLongPressGesture(minimumDuration:maximumDistance:perform:onPressingChanged:)

Adds an action to perform when this view recognizes a long press
gesture.

```
@export(implementation) nonisolated func onLongPressGesture(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10, perform action: @escaping () -> Void, onPressingChanged: ((Bool) -> Void)? = nil) -> some View
```

## Parameters

`minimumDuration`

The minimum duration of the long press that must
elapse before the gesture succeeds.

`maximumDistance`

The maximum distance that the fingers or cursor
performing the long press can move before the gesture fails.

`action`

The action to perform when a long press is recognized.

`onPressingChanged`

A closure to run when the pressing state of the
gesture changes, passing the current state as a parameter.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)