UIScreenEdgePanGestureRecognizer
UIScreenEdgePanGestureRecognizer represents a screen-edge pan gesture recognizer: it only recognizes drags that start at the edge of the screen and move inward. Otherwise it is the same as UIPanGestureRecognizer, and its event object also carries translation and velocity.
edges defaults to an empty array; until it is set, no gesture is recognized. Add the recognizer to a view that contains the screen edge, usually a view controller's full-screen view.
Three defaults differ from the parent class:
| Property | UIPanGestureRecognizer | UIScreenEdgePanGestureRecognizer |
|---|---|---|
maximumNumberOfTouches | 4294967295 | 1 |
delaysTouchesBegan | false | true |
edges | No such property | [] |
Screen-edge dragging has not been checked with real touches, and the gesture itself is not verified in the simulator.
Inheritance: EventTarget → NSObject → UIGestureRecognizer → UIPanGestureRecognizer → UIScreenEdgePanGestureRecognizer
For how to use it, see the guide Responding to gestures.
Constructor
UIScreenEdgePanGestureRecognizer()
Creates a screen-edge pan gesture recognizer. Set edges before it can recognize a gesture.
Instance properties
Also inherits the properties and methods of UIPanGestureRecognizer and UIGestureRecognizer, including translationInView(), velocityInView(), and setTranslation().
| Property | Description |
|---|---|
edges | Which screen edges a recognized drag can start from |
Events
The events come from UIGestureRecognizer; listen with addEventListener(). It fires:
| Event | When it fires |
|---|---|
began | When a drag from the edge is recognized |
changed | Each time the finger moves after that |
ended | When the finger lifts |
cancelled | When interrupted |
Examples
const page = new UIView();
const fromRight = new UIScreenEdgePanGestureRecognizer();
fromRight.edges = ['right'];
fromRight.addEventListener('began', () => {
console.log('Dragged in from the right edge');
});
page.addGestureRecognizer(fromRight);Effect: when page fills the screen, dragging a finger left from the right edge of the screen logs Dragged in from the right edge. A drag that starts in the middle of the screen logs nothing. Not verified in the simulator.
Corresponding iOS API
| ObjC | JS |
|---|---|
edgePan.edges = UIRectEdgeRight | edgePan.edges = ['right'] |
edgePan.edges = UIRectEdgeAll | edgePan.edges = ['top', 'left', 'bottom', 'right'] |
See also
- Responding to gestures
UIPanGestureRecognizer: the parent classUINavigationController: it uses drags from the left edge of the screen to go back to the previous view controller