UIPinchGestureRecognizer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.2 and later.
Companion guide
Declared in
UIPinchGestureRecognizer.h
Related sample code

Overview

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.

Tasks

Interpreting the Pinching Gesture

Properties

scale

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

@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.

Availability
  • Available in iOS 3.2 and later.
Related Sample Code
Declared In
UIPinchGestureRecognizer.h

velocity

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

@property(nonatomic, readonly) CGFloat velocity
Availability
  • Available in iOS 3.2 and later.
Declared In
UIPinchGestureRecognizer.h