iOS Developer Library

Developer

UIKit Framework Reference UIPinchGestureRecognizer Class Reference

Options
Deployment Target:

On This Page
Language:

UIPinchGestureRecognizer

UIPinchGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for pinching gestures involving two touches. When the user moves the two fingers toward each other, the conventional meaning is zoom-out; when the user moves the two fingers away from each other, the conventional meaning is zoom-in.

Pinching is a continuous gesture. The gesture begins (UIGestureRecognizerStateBegan) when the two touches have moved enough to be considered a pinch gesture. The gesture changes (UIGestureRecognizerStateChanged) when a finger moves (with both fingers remaining pressed). The gesture ends (UIGestureRecognizerStateEnded) when both fingers lift from the view.

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 3.2 and later.
  • scale scale Property

    The scale factor relative to the points of the two touches in screen coordinates.

    Declaration

    Swift

    var scale: CGFloat

    Objective-C

    @property(nonatomic) CGFloat scale

    Discussion

    You may set the scale factor, but doing so resets the velocity.

    The scale value is an absolute value that varies over time. It is not the delta value from the last time that the scale was reported. Apply the scale 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

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • velocity velocity Property

    The velocity of the pinch in scale factor per second. (read-only)

    Declaration

    Swift

    var velocity: CGFloat { get }

    Objective-C

    @property(nonatomic, readonly) CGFloat velocity

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.