maximumDistance
TypeScriptget maximumDistance(): numberSwift declarationnonisolated var maximumDistance: CGFloat { get set }The maximum distance that the long press can move before the gesture fails.
struct · iOS 13.0+ · SDK 27.1
nonisolated struct LongPressGestureA gesture that succeeds when the user performs a long press. To recognize a long-press gesture on a view, create and configure the gesture, then add it to the view using the ``View/gesture(_:including:)`` modifier. Add a long-press gesture to a ``Circle`` to animate its color from blue to red, and then change it to green when the gesture ends: struct LongPressGestureView: View { @GestureState private var isDetectingLongPress = false @State private var completedLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 3) .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState transaction.animation = Animation.easeIn(duration: 2.0) } .onEnded { finished in self.completedLongPress = finished } } var body: some View { Circle() .fill(self.isDetectingLongPress ? Color.red : (self.completedLongPress ? Color.green : Color.blue)) .frame(width: 100, height: 100, alignment: .center) .gesture(longPress) } }
get maximumDistance(): numberSwift declarationnonisolated var maximumDistance: CGFloat { get set }The maximum distance that the long press can move before the gesture fails.
set maximumDistance(value: number)Swift declarationnonisolated var maximumDistance: CGFloat { get set }The maximum distance that the long press can move before the gesture fails.
static initMinimumDurationMaximumDistanceInputKinds(minimumDuration?: number, maximumDistance?: number, inputKinds?: _SwiftUICore_GestureInputKinds): LongPressGestureSwift declarationnonisolated init(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10, inputKinds: GestureInputKinds = .all)Creates a long-press gesture with a minimum duration, a maximum distance, and the input kinds the gesture recognizes. - 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. - inputKinds: A set of input kinds that this gesture recognizes. If not specified, the gesture will recognize all applicable input kinds that a person can use to perform it.
static initMinimumDurationMaximumDistance(minimumDuration?: number, maximumDistance?: number): LongPressGestureSwift declarationnonisolated init(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10)Creates a long-press gesture with a minimum duration and a maximum distance that the interaction can move before the gesture fails. - 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.
get minimumDuration(): numberSwift declarationvar minimumDuration: DoubleThe minimum duration of the long press that must elapse before the gesture succeeds.
set minimumDuration(value: number)Swift declarationvar minimumDuration: DoubleThe minimum duration of the long press that must elapse before the gesture succeeds.
No declarations were skipped in this snapshot.