ZoomableUIView is a protocol that any UIView can conform to in order to be able to zoom and pan views without using UIScroll View. Particularly handy for views within UIScrollViews
ZoomableUIView is using swift3.
The simple code to get ZoomableUIView
running in your own app.
- In case you installed ZoomableUIView via CocoaPods you need to import it (add this somewhere at the top of your source code file):
import ZoomableUIView
- When you want to conform to the protocol:
class CustomView: UIView, ZoomableUIView
- Or:
extension CustomView: ZoomableUIView
- If you want to set the view zoomable:
self.setZoomable(true)
- When you want to reset the zoom:
self.reset()
- Mandatory protocol conformance
Works like UIScrollViewDelegate's viewForZooming. May well be that you want to use self in this case but you may want the current view to handle the zoom recognition and a subview to be zoomed, in that case return the subview in this func
func viewForZooming() -> UIView
Set zooming options such as min and max zoom
func optionsForZooming() -> ZoomableViewOptions
If you want to overwrite the default reset logic then feel free to implement
func reset()
But it's not required
UIKit must be imported. If you are using ZoomableUIView in an App Extension, you must add EXTENSION
to your Other Swift Flags
Build Settings.
ZoomableUIView
is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "ZoomableUIView"
In case you don’t want to use CocoaPods - just copy the files ZoomableUIView/ZoomableUIView.swift & ZoomableUIView/CGAffineTransform.swift to your Xcode project.
Author: James Coughlan
**ZoomableUIView**
is available under the MIT license. See the LICENSE file for more info.