PanTilt
A structure for describing zoom and a gesture recognizer that allows for modifying it
- Can be incorporated into any view used for displaying a photo, drawing canvas, etc.
- Gives transformation matrices for converting between screen and context coordinates
- Two-finger gesture supports zoom, pan and tilt
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Implementation
- Make your view conform to
ZoomableView
- At each drawing pass, use the
canvasToView()
function of thezoom
property to get a matrix for drawing your content - Initialise and attach a
PanTiltGestureRecognizer
to your view - (Optional) You can make the gesture delegate conform to
PanTiltGestureRecognizerDelegate
if you want to handle events such as start or update of zoom gesture. - (Optional) You can restrict the zoom range by creating an object implementing the
PanTiltGestureRecognizerZoomDelegate
and attaching it to thezoomSnap
property of the gesture. You can see how this is done in the example project.
Requirements
- Swift 4.2
This is an iOS project, but is should be easy to adapt it for macOS too if needed.
Installation
PanTilt is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PanTilt'
Author
hristost, [email protected]
License
PanTilt is available under the MIT license. See the LICENSE file for more info.