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

Dhvl-Golakiya/ImageSlideshow

 
 

Repository files navigation

ImageSlideshow

Build Status Version Carthage Compatible License Platform

ImageSlideshow

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

Usage

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

Swift 2.3 and Swift 3 support

Version 1.0-beta.1 supports Swift 3. For Swift 2.2 and Swift 2.3 compatible code use version 0.6 or branch swift-2.3.

Installation

CocoaPods

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

pod 'ImageSlideshow', '~> 1.0.0-beta.1'

Carthage

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

github "zvonicek/ImageSlideshow" "1.0.0-beta.1"

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 three more InputSources available:

AlamofireImage

pod "ImageSlideshow/Alamofire"

Used by creating a new AlamofireSource instance:

AlamofireSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")

AFNetworking

pod "ImageSlideshow/AFURL"

Used by creating a new AFURLSource instance:

AFURLSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")

SDWebImage

pod "ImageSlideshow/SDWebImage"

Used by creating a new SDWebImageSource instance:

SDWebImageSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")

Kingfisher

pod "ImageSlideshow/Kingfisher"

Used by creating a new KingfisherSource instance:

KingfisherSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")

Configuration

Behaviour is configurable by those 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
  • currentPageChanged - closure called on page change
  • preload - image preloading configuration (all images are preloaded by default)

Full Screen view

There is also a possibility to open full-screen image view using attached FullScreenSlideshowViewController. The simplest way is to call:

override func viewDidLoad() {
  let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.didTap))
  slideshow.addGestureRecognizer(gestureRecognizer)
}

func didTap() {
  slideshow.presentFullScreenController(from: self)
}

FullScreenSlideshowViewController can also be instantiated and configured manually if more advanced behavior is needed.

Author

Petr Zvoníček

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

 
 
 

Languages

  • Swift 93.0%
  • Ruby 5.9%
  • Objective-C 1.1%