iOS Developer Library

Developer

UIKit Framework Reference UIPanGestureRecognizer Class Reference

Options
Deployment Target:

On This Page
Language:

UIPanGestureRecognizer

UIPanGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for panning (dragging) gestures. The user must be pressing one or more fingers on a view while they pan it. Clients implementing the action method for this gesture recognizer can ask it for the current translation and velocity of the gesture. More...

Conforms To


Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 3.2 and later.
  • The maximum number of fingers that can be touching the view for this gesture to be recognized.

    Declaration

    Swift

    var maximumNumberOfTouches: Int

    Objective-C

    @property(nonatomic) NSUInteger maximumNumberOfTouches

    Discussion

    The default value is NSUIntegerMax.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • The minimum number of fingers that can be touching the view for this gesture to be recognized.

    Declaration

    Swift

    var minimumNumberOfTouches: Int

    Objective-C

    @property(nonatomic) NSUInteger minimumNumberOfTouches

    Discussion

    The default value is 1.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • The translation of the pan gesture in the coordinate system of the specified view.

    Declaration

    Swift

    func translationInView(_ view: UIView) -> CGPoint

    Objective-C

    - (CGPoint)translationInView:(UIView *)view

    Parameters

    view

    The view in whose coordinate system the translation of the pan gesture should be computed. If you want to adjust a view's location to keep it under the user's finger, request the translation in that view's superview's coordinate system.

    Return Value

    A point identifying the new location of a view in the coordinate system of its designated superview.

    Discussion

    The x and y values report the total translation over time. They are not delta values from the last time that the translation was reported. Apply the translation value to the state of the view when the gesture is first recognized—do not concatenate the value each time the handler is called.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Sets the translation value in the coordinate system of the specified view.

    Declaration

    Swift

    func setTranslation(_ translation: CGPoint, inView view: UIView!)

    Objective-C

    - (void)setTranslation:(CGPoint)translation inView:(UIView *)view

    Parameters

    translation

    A point that identifies the new translation value.

    view

    A view in whose coordinate system the translation is to occur.

    Discussion

    Changing the translation value resets the velocity of the pan.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • The velocity of the pan gesture in the coordinate system of the specified view.

    Declaration

    Swift

    func velocityInView(_ view: UIView!) -> CGPoint

    Objective-C

    - (CGPoint)velocityInView:(UIView *)view

    Parameters

    view

    The view in whose coordinate system the velocity of the pan gesture is computed.

    Return Value

    The velocity of the pan gesture, which is expressed in points per second. The velocity is broken into horizontal and vertical components.

    Import Statement

    import UIKit

    Availability

    Available in iOS 3.2 and later.