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 projectCreate CocoaPodFix initial bugsPolish API- Improve documentation
- Improve the example project to demonstrate all the features
InputSource subclass for Alamofire (yay!)
To run the example project, clone the repo, and run pod install
from the Example directory first.
Version 0.6 supports both Swift 2.2 and Swift 2.3. Code fully compatible with Swift 3 can be found in branch swift-3 and will be oficially released in a future update.
ImageSlideshow is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ImageSlideshow', '~> 0.6'
To integrate ImageSlideshow into your Xcode project using Carthage, specify it in your Cartfile:
github "zvonicek/ImageSlideshow" ~> 0.6
You can instantiate Slideshow either in Storyboard / Interface Builder, or in code.
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:
pod "ImageSlideshow/Alamofire"
Used by creating a new AlamofireSource
instance:
AlamofireSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")
pod "ImageSlideshow/AFURL"
Used by creating a new AFURLSource
instance:
AFURLSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")
pod "ImageSlideshow/SDWebImage"
pod "ImageSlideshow/Kingfisher"
Used by creating a new KingfisherSource
instance:
KingfisherSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080")
Behaviour is configurable by those properties:
slideshowInterval
- in case you want automatic slideshow, set up the interval between sliding to next picturezoomEnabled
- enables zoomingcircular
- enables circular scrollingpageControlPosition
- configures position of UIPageControll (hidden, inside scroll view or under scroll view)contentScaleMode
- configures the scaling (UIViewContentMode.ScaleAspectFit by default)draggingEnabled
- enables dragging
There is also a possibility to open full-screen image view using attached FullScreenSlideshowViewController
. The controller is meant to be presented manually, as seen on the example:
var slideshowTransitioningDelegate: 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 in
self.slideshow.setScrollViewPage(page, animated: false)
}
// set the initial page
ctr.initialImageIndex = slideshow.scrollViewPage
// set the inputs
ctr.inputs = slideshow.images
self.slideshowTransitioningDelegate = ZoomAnimatedTransitioningDelegate(slideshowView: slideshow, slideshowController: ctr)
ctr.transitioningDelegate = self.slideshowTransitioningDelegate
self.presentViewController(ctr, animated: true, completion: nil)
}
Petr Zvoníček
ImageSlideshow is available under the MIT license. See the LICENSE file for more info.
Inspired by projects: