Go to file
suzuki_keishi 50fe55684f clean browser. 2016-08-23 14:54:09 +09:00
SKPhotoBrowser clean browser. 2016-08-23 14:54:09 +09:00
SKPhotoBrowser.xcodeproj clean. 2016-08-18 17:29:13 +09:00
SKPhotoBrowserExample clean browser. 2016-08-23 14:35:58 +09:00
SKPhotoBrowserTests If image downloaded then not show activityindicator 2016-07-30 15:34:51 +05:00
Screenshots [update]minor update for example. readme. 2016-03-17 19:43:52 +09:00
.gitignore [add]first commit. 2015-10-09 15:19:43 +09:00
.swiftlint.yml [update]some delegate goes to optional. 2016-02-22 10:24:23 +09:00
.travis.yml [update]delegate add for actionbutton. 2016-02-02 14:14:45 +09:00
CHANGELOG.md [add]change log. 2016-08-18 11:06:39 +09:00
LICENSE [add]first commit. 2015-10-09 15:19:43 +09:00
README.md clean, refactor, update readme. 2016-08-23 14:02:01 +09:00
SKPhotoBrowser.podspec update pod spec. 2016-08-05 10:59:14 +09:00

README.md

SKPhotoBrowser

Carthage Compatible Cocoapods Compatible

Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift, based on IDMPhotoBrowser, MWPhotoBrowser.

features

  • Display one or more images by providing either UIImage objects, or string of URL array.
  • Photos can be zoomed and panned, and optional captions can be displayed
  • Minimalistic Facebook-like interface, swipe up/down to dismiss
  • Ability to custom control. (hide/ show toolbar for controls, / swipe control)
  • Handling and caching photos from web
  • Landscape handling
  • Delete photo support(by offbye). By set displayDelete=true show a delete icon in statusbar, deleted indexes can be obtain from delegate func didDeleted

sample

Requirements

  • iOS 8.0+
  • Swift 2.0+
  • ARC

##Installation

####CocoaPods available on CocoaPods. Just add the following to your project Podfile:

pod 'SKPhotoBrowser'
use_frameworks!

####Carthage To integrate into your Xcode project using Carthage, specify it in your Cartfile:

github "suzuki-0000/SKPhotoBrowser"

####Manually Add the code directly into your project.

##Usage See the code snippet below for an example of how to implement, or see the example project.

from UIImages:

// 1. create SKPhoto Array from UIImage
var images = [SKPhoto]()
let photo = SKPhoto.photoWithImage(UIImage())// add some UIImage
images.append(photo) 

// 2. create PhotoBrowser Instance, and present from your viewController. 
let browser = SKPhotoBrowser(photos: images)
browser.initializePageIndex(0)
presentViewController(browser, animated: true, completion: {})

from URLs:

// 1. create URL Array 
var images = [SKPhoto]()
let photo = SKPhoto.photoWithImageURL("https://placehold.jp/150x150.png")
photo.shouldCachePhotoURLImage = false // you can use image cache by true(NSCache)
images.append(photo)

// 2. create PhotoBrowser Instance, and present. 
let browser = SKPhotoBrowser(photos: images)
browser.initializePageIndex(0)
presentViewController(browser, animated: true, completion: {})

from local files:

// 1. create images from local files
var images = [SKLocalPhoto]()
let photo = SKLocalPhoto.photoWithImageURL("..some_local_path/150x150.png")
images.append(photo)

// 2. create PhotoBrowser Instance, and present. 
let browser = SKPhotoBrowser(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) 
   let originImage = cell.exampleImageView.image // some image for baseImage 

   let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell) 
   browser.initializePageIndex(indexPath.row)
   presentViewController(browser, animated: true, completion: {})
}

Custom

Toolbar

You can customize Toolbar via SKPhotoBrowserOptions.

  • displayCounterLabel (default is true)
  • displayBackAndForwardButton (default is true)
  • displayAction (default is true)
SKPhotoBrowserOptions.displayToolbar = false                // all tool bar will be hidden
SKPhotoBrowserOptions.displayCounterLabel = false           // counter label will be hidden
SKPhotoBrowserOptions.displayBackAndForwardButton = false   // back / forward button will be hidden
SKPhotoBrowserOptions.displayAction = false                 // action button will be hidden
SKPhotoBrowserOptions.displayDeleteButton = true            // delete button will be shown
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)

CustomButton Image

Close button is able to change image and frame.

browser.displayCustomCloseButton = true // custom close button will be enable
browser.customCloseButtonImage = UIImage(named: "some.png")
browser.customCloseButtonShowFrame = CGRect()
browser.customCloseButtonHideFrame = CGRect()

Delete button is able to change image and frame.

browser.displayCustomDeleteButton = true // custom delete button will be enable
browser.customDeleteButtonImage = UIImage(named: "some.png")
browser.customDeleteButtonShowFrame = CGRect()
browser.customDeleteButtonHideFrame = CGRect()

Delete

You can delete your photo for your own hanlding.

Photo Captions

Photo captions can be displayed simply bottom of PhotoBrowser. by setting the caption property on specific photos:

let photo = SKPhoto.photoWithImage(UIImage())
photo.caption = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
images.append(photo)

SwipeGesture

vertical swipe can enable/disable:

let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.disableVerticalSwipe = true 

Delegate

There's some trigger point you can handle using delegate. those are optional.

  • didShowPhotoAtIndex(index:Int)
  • willDismissAtPageIndex(index:Int)
  • willShowActionSheet(photoIndex: Int)
  • didDismissAtPageIndex(index:Int)
  • didDismissActionSheetWithButtonIndex(buttonIndex: Int, photoIndex: Int)
  • didScrollToIndex(index: Int)
  • removePhoto(browser: SKPhotoBrowser, index: Int, reload: (() -> Void))
  • viewForPhoto(browser: SKPhotoBrowser, index: Int) -> UIView?
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.delegate = self

// MARK: - SKPhotoBrowserDelegate
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
}

Minor Option

  • blackArea handling which is appearing outside of photo
  • single tap handling, dismiss/noaction
  • bounce animation when appearing/dismissing
enableZoomBlackArea    = true  // default true
enableSingleTapDismiss = true  // default false
bounceAnimation        = true  // default false

Photos from

License

available under the MIT license. See the LICENSE file for more info.