A control to help you display an image, with zoomable and scrollable features easily.
When you make an application, which has a photo viewer feature, the photo viewer usually needs to have zoomable and scrollable features, to allow the user to view more photo details.
This control help you display image, with zoomable and scrollable features easily.
- iOS 7 and later (requires iOS 8 if you want to add it to project using CocoaPod)
- Swift 3.0 (version 1.3), 2.0 (version 1.2 and prior)
Add below line to Podfile:
pod 'ImageScrollView'
and run below command in Terminal to install:
pod install
Note: If above pod isn't working, try using below pod definition in Podfile:
pod 'ImageScrollView', :git => 'https://github.com/huynguyencong/ImageScrollView.git'
In iOS 7, you cannot use Cocoapod to install. In this case, you need add it manually. Simply, add file ImageSrollView.swift
in folder Sources
to your project
Drag an UIScrollView to your storyboard, change Class and Module in Identity Inspector to ImageScrollView. Also, create an IBOutlet in your source file.
import ImageScrollView
@IBOutlet weak var imageScrollView: ImageScrollView!
let myImage = UIImage(named: "my_image_name")
imageScrollView.display(image: myImage)
That's all. Now try zooming and scrolling to see the result.
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:
- Double tap to zoom feature.
- Smoother. Fixed bug when zooming out, the control auto zooms from center, and not from the corner.
ImageScrollView is released under the MIT license. See LICENSE for details. Copyright © Nguyen Cong Huy