TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2015 |
SPMSupports SPM | ✗ |
Maintained by suzuki-0000.
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0, based on IDMPhotoBrowser, MWPhotoBrowser.
UIImage
objects, or string of URL array.Add the code directly into your project.
See the code snippet below for an example of how to implement, or example project would be easy to understand.
// add SwipablePhoto Array from UIImage
var images = [SwipablePhoto]()
let photo = SwipablePhoto.photoWithImage(UIImage())// add some UIImage
images.append(photo)
// create PhotoBrowser Instance, and present.
let browser = SwipablePhotoBrowser(photos: images)
browser.initializePageIndex(indexPath.row)
browser.delegate = self
presentViewController(browser, animated: true, completion: {})
from web URLs:
// URL pattern snippet
var images = [SwipablePhoto]()
let photo = SwipablePhoto.photoWithImageURL("https://placehold.jp/150x150.png")
photo.shouldCachePhotoURLImage = false // you can use image cache by true(NSCache)
images.append(photo)
// create PhotoBrowser Instance, and present.
let browser = SwipablePhotoBrowser(photos: images)
browser.initializePageIndex(0)
presentViewController(browser, animated: true, completion: {})
If you want to use zooming effect from an existing view, use another initializer:
// e.g.: some tableView or collectionView.
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! ExampleCollectionViewCell
let originImage = cell.exampleImageView.image! // some image for baseImage
let browser = SwipablePhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.initializePageIndex(indexPath.row)
presentViewController(browser, animated: true, completion: {})
}
You can customize the toolbar(back/forward, counter) button.
let browser = SwipablePhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.displayToolbar = false // all tool bar will be hidden
browser.displayCounterLabel = false // counter label will be hidden
browser.displayBackAndForwardButton = false // back / forward button will be hidden
Photo captions can be displayed simply bottom of PhotoBrowser. by setting the caption
property on specific photos:
let photo = SwipablePhoto.photoWithImage(UIImage())
photo.caption = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
images.append(photo)
vertical swipe can enable/disable:
let browser = SwipablePhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.disableVerticalSwipe = true
you can hide statusbar forcely using property:
let browser = SwipablePhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.isForceStatusBarHidden = true
There’s some trigger point you can handle using delegate.
let browser = SwipablePhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.delegate = self
// MARK: - SwipablePhotoBrowserDelegate
func didShowPhotoAtIndex(index: Int) {
// when photo will be shown
}
func willDismissAtPageIndex(index: Int) {
// when PhotoBrowser will be dismissed
}
func didDismissAtPageIndex(index: Int) {
// when PhotoBrowser did dismissed
}
available under the MIT license. See the LICENSE file for more info.