https://github.com/hkalexling/awimageviewcontroller
:camera: A neat and lightweight image viewer written in Swift
https://github.com/hkalexling/awimageviewcontroller
Last synced: about 2 months ago
JSON representation
:camera: A neat and lightweight image viewer written in Swift
- Host: GitHub
- URL: https://github.com/hkalexling/awimageviewcontroller
- Owner: hkalexling
- License: wtfpl
- Created: 2015-12-06T06:00:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-29T07:24:15.000Z (about 9 years ago)
- Last Synced: 2025-04-11T15:11:04.624Z (about 2 months ago)
- Language: Swift
- Homepage:
- Size: 113 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWImageViewController
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](https://github.com/hkalexling/AWImageViewController/tree/master/Source) into your project and do the following setup
####Basic usage without customisation:
```swift
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:
```swift
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:```swift
progressIndicatorColor : UIColor
progressIndicatorTextColor : UIColor
progressIndicatorBgColor : UIColor
progressIndicatorShowLabel : Bool
progressIndicatorWidth : CGFloat
progressIndicatorLabelFont : UIFont
progressIndicatorRadius : CGFloat
```####Delegates:
- `AWImageViewControllerDelegate`: Conform to this delegate and implement its delegate method `awImageViewDidDismiss()` to get callback when the image viewer has been dismissed
- `AWImageViewControllerLongPressDelegate`: Conform to this delegate and implement its delegate method `awImageViewDidLongPress()` 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
- [X] Integrate an image downloader to download image from a given URL
- [X] Use a better looking progress indicator
- [ ] GIF support
- [ ] Use optional placeholder image before download finished
- [ ] Implement 3D Touch peek and pop