A neat and lightweight image viewer written in Swift
##Demo GIF
- Portrait Mode:
- Landscape Mode:
- Use Web Image:
##Features
Basically everything you will expect for an image viewer:
- Single tap to dismiss
- Double taps to zoom in/out
- Pinch to zoom in/out
- Pan when zoomed in
- Long press to bring up action sheet (customisable)
- Different background effects to choose from (three blur effects and one simple black background)
- Transition with animation
- download image from provided URL
##Usage
Add the files in the Source folder into your project and do the following setup
####Basic usage without customisation:
class SampleClass : UIViewController {
//Create instance of AWImageViewController as a global variable
var awImageVC : AWImageViewController!
//Other stuff
func showImageViewer(imageView : UIImageView){
self.awImageVC = AWImageViewController()
self.awImageVC.setup(imageView, parentView: self.view, backgroundStyle: .LightBlur, animationDuration: nil, delegate: nil, longPressDelegate: nil)
self.collectionView!.addSubview(self.awImageVC.view)
}
}
####Download image from URL:
class SampleClass : UIViewController {
//Create instance of AWImageViewController as a global variable
var awImageVC : AWImageViewController!
//Other stuff
func showImageViewer(urlString : String) {
self.awImageVC = AWImageViewController()
self.awImageVC.setupWithUrl(urlString, parentView: self.view, backgroundStyle: nil, animationDuration: nil, delegate: nil, longPressDelegate: nil)
self.view.addSubview(self.awImageVC.view)
}
}
AWImageViewController
also provides the following variables for you to customize the progress indicator:
progressIndicatorColor : UIColor
progressIndicatorTextColor : UIColor
progressIndicatorBgColor : UIColor
progressIndicatorShowLabel : Bool
progressIndicatorWidth : CGFloat
progressIndicatorLabelFont : UIFont
progressIndicatorRadius : CGFloat
####Delegates:
AWImageViewControllerDelegate
: Conform to this delegate and implement its delegate methodawImageViewDidDismiss()
to get callback when the image viewer has been dismissedAWImageViewControllerLongPressDelegate
: Conform to this delegate and implement its delegate methodawImageViewDidLongPress()
to override what will happen when user perform long press on the image
####Others:
For more detail usages, please refer to the two demo apps included in this repo
##Todo
- Integrate an image downloader to download image from a given URL
- Use a better looking progress indicator
- GIF support
- Use optional placeholder image before download finished
- Implement 3D Touch peek and pop