A structure for describing zoom and a UIGestureRecognizer
that allows for modifying it.
- Can be used for any view with custom drawing code. Use this when you need to provide a zoom interaction but can't afford a
UIScrollView
- Gives transformation matrices for converting between screen and context coordinates
- Two-finger gesture supports zoom, pan and tilt
Used in Amaziograph.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- 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.
- Swift 5.0
- UIKit
PanTilt is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PanTilt'
hristost, hristo.staykov@gmail.com
PanTilt is available under the MIT license. See the LICENSE file for more info.