Simple Zoomable Scroll View inherited from UIScrollView
MIT License
A Simple Zoomable ScrollView with a View inherited from UIScrollView.
When you make an application, which has a viewer feature(like big photo viewer), the viewer usually needs to have zoomable and scrollable features, to allow the user to view more details. This control help you display a view, with zoomable and scrollable features easily.
Add below line to Podfile or Run below command in Terminal to install(not support pod api yet):
pod 'ZoomableScrollView', :git => 'https://github.com/tucan9389/ZoomableScrollView.git'
In iOS 7, you cannot use Cocoapod to install. In this case, you need add it manually. Simply, add file ZoomableScrollView.swift
in folder Sources
to your project
Drag an UIScrollView to your storyboard, change Class and Module in Identity Inspector to ZoomableScrollView. Also, create an IBOutlet in your source file.
import ZoomableScrollView
class ViewController: UIViewController
@IBOutlet weak var zoomableScrollView: ZoomableScrollView!
let myView = MyCustomView()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
zoomableScrollView.display(view: myView)
// or
zoomableScrollView.display(image: UIImage(named: "image"))
}
}
That's all. Now try zooming and scrolling to see the result.
Note: If your view is aligned left instead of center, try calling below method:
superViewOfZoomableScrollView.layoutIfNeeded()
superViewOfZoomableScrollView
is the view that ZoomableScrollView is added to.
ZoomMode
(.defaultFit
, aspectFill
, aspectFit
, widthFill
, heightFill
)This open source is based on PhotoScroller demo avaiable on Apple's site. The original source is written in Objective C. This source rewrite uses Swift, and adds some new features
ZoomableScrollView is released under the MIT license. See LICENSE for details. Copyright tucan9389