Skip to content

Swift image slideshow with circular scrolling, timer and full screen viewer

License

Notifications You must be signed in to change notification settings

shomishinec/ImageSlideshow

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageSlideshow

CI Status Version License Platform

ImageSlideshow

iOS / Swift image slideshow with circular scrolling, timer and full screen viewer.

This component is under development. Description and brief documentation will follow with future versions. The API will be subject of change.

Roadmap for 1.0:

  • Create test project
  • Create CocoaPod
  • Fix initial bugs
  • Polish API
  • Write brief documentation
  • InputSource subclass for Alamofire (yay!)

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

ImageSlideshow is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ImageSlideshow', '~> 0.4'

Usage

You can instantiate Slideshow either in Storyboard / Interface Builder, or in code.

Loading images

Images can be set by calling setImageInputs method on ImageSlideshow instance. Argument is an array of InputSources. By default you may use ImageSource which takes UIImage, but you can easily subclass InputSource and support your own input source.

slideshow.setImageInputs([ImageSource(image: UIImage(named: "myImage"))!, ImageSource(image: UIImage(named: "myImage2"))!,])

There are two more InputSources available:

AlamofireImage

AlamofireSource subspec allowing to load image from URL using AlamofireImage. To use this add the Alamofire subspec to your Podfile.

pod "ImageSlideshow/Alamofire"

It is then possible to load image from URL by calling

AlamofireSource(urlString: "https://upload.wikimedia.org/wikipedia/commons/d/d5/Trencin_hdr_001.jpg")

AFNetworking

AFURL subspec allowing to load image from URL using AFNetworking. To use this add the AFURL subspec to your Podfile.

pod "ImageSlideshow/AFURL"

It is then possible to load image from URL by calling

AFURLSource(urlString: "https://upload.wikimedia.org/wikipedia/commons/d/d5/Trencin_hdr_001.jpg")

Configuration

It is possible to configure behaviour by setting numerous properties:

  • slideshowInterval - in case you want automatic slideshow, set up the interval between sliding to next picture
  • zoomEnabled - enables zooming
  • circular - enables circular scrolling
  • pageControlPosition - configures position of UIPageControll (hidden, inside scroll view or under scroll view)
  • contentScaleMode - configures the scaling (UIViewContentMode.ScaleAspectFit by default)
  • draggingEnabled - enables dragging

Full Screen view

As seen on sample image and example project, you may also use full-scren view. For now there is a need to present the controller manually.

var transitionDelegate: ZoomAnimatedTransitioningDelegate?

override func viewDidLoad() {
  ...
  let gestureRecognizer = UITapGestureRecognizer(target: self, action: "openFullScreen")
  slideshow.addGestureRecognizer(gestureRecognizer)
}

func click() {
  let ctr = FullScreenSlideshowViewController()
  // called when full-screen VC dismissed and used to set the page to our original slideshow
  ctr.pageSelected = {(page: Int) in
    self.slideshow.setScrollViewPage(page, animated: false)
  }
  
  // set the initial page
  ctr.initialPage = slideshow.scrollViewPage
  // set the inputs
  ctr.inputs = slideshow.images
  self.transitionDelegate = ZoomAnimatedTransitioningDelegate(slideshowView: slideshow, slideshowController: ctr)
  ctr.transitioningDelegate = self.transitionDelegate
  self.presentViewController(ctr, animated: true, completion: nil)
}

Author

Petr Zvoníček, zvonicek@gmail.com

License

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

References

Inspired by projects:

About

Swift image slideshow with circular scrolling, timer and full screen viewer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.3%
  • Ruby 5.7%