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

Overview

🖼 ImageSlideshow

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

Build Status Version Carthage Compatible License Platform

📱 Example

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

🔧 Installation

CocoaPods

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

pod 'ImageSlideshow', '~> 1.9.0'

Carthage

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

github "zvonicek/ImageSlideshow" ~> 1.9.0

Carthage does not include InputSources for external providers (due to dependency on those providers) so you need to grab the one you need from ImageSlideshow/Classes/InputSources manually.

Manually

One possibility is to download a built framework (ImageSlideshow.framework.zip) from releases page and link it with your project (underLinked Frameworks and Libraries in your target). This is, however, currently problematic because of rapid Swift development -- the framework is built for a single Swift version and may not work on previous/future versions.

Alternatively can also grab the whole ImageSlideshow directory and copy it to your project. Be sure to remove those external Input Sources you don't need.

Note on Swift 2.3, Swift 3 and Swift 4 support

Version 1.4 supports Swift 4. Swift 3 is supported from version 1.0, for Swift 2.2 and Swift 2.3 compatible code use version 0.6 or branch swift-2.3.

🔨 How to use

Add ImageSlideshow view to your view hiearchy either in Interface Builder or in code.

Loading images

Set images by using setImageInputs method on ImageSlideshow instance with an array of InputSources. By default you can use ImageSource which takes UIImage or few other InputSources for most popular networking libraries. You can also create your own input source by implementing InputSource protocol.

Library InputSource name Pod
AlamofireImage AlamofireSource pod "ImageSlideshow/Alamofire"
AFNetworking AFURLSource pod "ImageSlideshow/AFURL"
SDWebImage SDWebImageSource pod "ImageSlideshow/SDWebImage"
Kingfisher KingfisherSource pod "ImageSlideshow/Kingfisher"
Parse ParseSource pod "ImageSlideshow/Parse"
slideshow.setImageInputs([
  ImageSource(image: UIImage(named: "myImage"))!,
  ImageSource(image: UIImage(named: "myImage2"))!,
  AlamofireSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080"),
  KingfisherSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080"),
  ParseSource(file: PFFile(name:"image.jpg", data:data))
])

Configuration

Behaviour is configurable by those properties:

  • slideshowInterval - slideshow interval in seconds (default 0 – disabled)
  • zoomEnabled - enables zooming (default false)
  • circular - enables circular scrolling (default true)
  • activityIndicator – allows to set custom activity indicator, see Activity indicator section
  • pageIndicator – allows to set custom page indicator, see Page indicator section; assign nil to hide page indicator
  • pageIndicatorPosition - configures position of the page indicator
  • contentScaleMode - configures the scaling (default ScaleAspectFit)
  • draggingEnabled - enables dragging (default true)
  • currentPageChanged - closure called on page change
  • willBeginDragging - closure called on scrollViewWillBeginDragging
  • didEndDecelerating - closure called on scrollViewDidEndDecelerating
  • preload - image preloading configuration (default all preloading, also fixed)

Page Indicator

Page indicator can be customized using the pageIndicator property on ImageSlideshow. By defualt, a plain UIPageControl is used. If needed, page control can be customized:

let pageIndicator = UIPageControl()
pageIndicator.currentPageIndicatorTintColor = UIColor.lightGray
pageIndicator.pageIndicatorTintColor = UIColor.black
slideshow.pageIndicator = pageIndicator

Also, a simple label page indicator that shows pages in style "5/21" (fifth page from twenty one) is provided:

slideshow.pageIndicator = LabelPageIndicator()

You can also use your own page indicator by adopting the PageIndicatorView protocol.

Position of the page indicator can be configured by assigning a PageIndicatorPosition value to the pageIndicatorPosition property on ImageSlideshow. You may specify the horizontal and vertical positioning separately.

Horizontal positioning options are: .left(padding: Int), .center, .right(padding: Int)

Vertical positioning options are: .top, .bottom, .under, customTop(padding: Int), customBottom(padding: Int), customUnder(padding: Int)

Example:

slideshow.pageIndicatorPosition = PageIndicatorPosition(horizontal: .left(padding: 20), vertical: .bottom)

Activity Indicator

By default activity indicator is not shown, but you can enable it by setting DefaultActivityIndicator instance to Image Slideshow:

slideshow.activityIndicator = DefaultActivityIndicator()

You can customize style and color of the indicator:

slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil)

There's also an option to use your own activity indicator. You just need to implement ActivityIndicatorView and ActivityIndicatorFactory protocols. See ActivityIndicator.swift for more information.

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:

Comments
  • ImageSlideShow shows blank screen when I change the input source list to a single item list

    ImageSlideShow shows blank screen when I change the input source list to a single item list

    Hi,

    I have an old project in Swift 3 with ImageSlideShow 1.3.2 (XCode 8). It works fine like this:

    • I show a dialog of ImageSlideShow with a list of some InputSource items (name as list A).
    • When user taps Delete button on dialog, I delete the current InputSource item in list A, then I call ImageSliceShow.setImageInputs(A) to reload the slide show.

    Now I upgrade the project up to Swift 5 with ImageSlideShow latest (1.8.0) (with XCode 10.2 - latest iOS SDK). There's an issue:

    • It works fine if I show ImageSlideShow dialog with list A containing 1 item (I mean setImageInputs(A) works fine at first time).
    • With list A count > 2, when I delete item in A and call setImageInputs(A) to reload the slide show, it works fine.
    • But when list A has 2 items, I delete 1 item so list A now contains only 1, then I call setImageInputs(A). ImageSlideShow now shows blank screen. (In Debug View Hierarchy, there's no subview in ImageSlideShow.scrollview).

    I apply that deleting spec into example project & get same issue.

    Please check, thank you!

    opened by soleilpqd 10
  • Sometimes crack app when tapping for full-screen!

    Sometimes crack app when tapping for full-screen!

    I see this issue when images from url loading. At that time, I tap to show full-screen, and I swipe to close. I see the app cracks! someone can tell me the reason and solutions for this.

    opened by Kent-Mbn 9
  • Must I use pod

    Must I use pod "ImageSlideshow/Kingfisher" even if I already have Kingfisher

    Must I use pod "ImageSlideshow/Kingfisher" even if I already have Kingfisher installed, or can I simply use pod 'ImageSlideshow', '~> 0.6' ?

    opened by kiwo12345 9
  • 'pageControlPosition' is deprecated: Use pageIndicatorPosition instead

    'pageControlPosition' is deprecated: Use pageIndicatorPosition instead

    First of all, I wanna say thank you very much for this great library :)

    I have a little bit issue in here, I get a warning

    'pageControlPosition' is deprecated: Use pageIndicatorPosition instead

    I get the error in here

    open class FullScreenSlideshowViewController: UIViewController {
    
        open var slideshow: ImageSlideshow = {
            let slideshow = ImageSlideshow()
            slideshow.zoomEnabled = true
            slideshow.contentScaleMode = UIViewContentMode.scaleAspectFit
            slideshow.pageControlPosition = PageControlPosition.insideScrollView
            // turns off the timer
            slideshow.slideshowInterval = 0
            slideshow.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
    
            return slideshow
        }()
    
    

    but when I change pageControlPosition to pageIndicatorPostion, it is said that pageIndicatorPostion doesn't have insideScrollView method

    I am using pod 'ImageSlideshow', '~> 1.6'

    opened by AgungLaksana 8
  • Slideshow Stops Transitionining

    Slideshow Stops Transitionining

    Hi, I'm using the slideshow and it only makes one transition for me (regardless of the time interval I've set, or how many images I've loaded in the input array). I have the slideshow in multiple places in my app, and this happens in every single place. I've tried mirroring the example given as closely as possible.

    Thanks!

    opened by samhinsh 8
  • Crash after exit from fullscreen

    Crash after exit from fullscreen

    Hi there. When the image is in fullscreen mode and I try to exit fullscreen. The App crashes and goes back to Root View (LoginPage). Has this happened to anyone else?

    I am running a separate app and it works fine. My code is following the instructions.

    Can anyone help?

    Also can anyone think of a way to stop viewDidAppear/Disappear being called when I enter/exit fullscreen mode?

    Thanks

    opened by maley63 6
  • SDWebImageSource not exist

    SDWebImageSource not exist

    There is no way that the SDWebImageSource class finds me, whereas the ImageSource works without problems.

    `let ab: [InputSource] = items.map { SDWebImageSource(urlString: $0.url)! }

        slideshow.setImageInputs(ab)`
    

    Use of unresolved identifier 'SDWebImageSource'

    I've load "import SDWebImage"

    Any ideas? Thnks!

    opened by alexllao 6
  • iOS 11 memory usage

    iOS 11 memory usage

    Each of our reusable tableview cells have an imageslideshow. When scrolling, the memory jumps from 30mb to 160mb and cpu from 0 to 70%. The memory remains at 160mb even though we dequeue our tableview cells. The only code we have for imageslideshow is setting the image inputs via SDWebImageSource.

    We tried a device on iOS 10.3.3 and this issue doesn't occur. Devices we try on iOS 11 have this issue.

    Any ideas?

    opened by georgehl 6
  • zoomEnabled not working

    zoomEnabled not working

    All the settings are working just fine. Although "zoomEnabled" does not seem to have any effect on the sideshow.

    This is the code

    var images = self.photos.map { (photo) -> KingfisherSource in
      return KingfisherSource(urlString: photo.imageUrl)!
    }
    self.slideshow.setImageInputs(images)
    self.slideshow.setCurrentPage(self.startPosition, animated: false)
    self.slideshow.circular = false
    self.slideshow.zoomEnabled = true
    self.slideshow.pageControlPosition = .hidden
    

    What I am looking for is, either a doubleTap to zoom the image or pinch gesture.

    Any thoughts on this?

    opened by prakashraman 6
  • Fullscreen initial image bug when slideshow is not circular

    Fullscreen initial image bug when slideshow is not circular

    When I have multiple images in my slideshow and set slideshow.circular = false, then click on an image to present in full screen would not present the current image I tapped. It would actually load the previous image! So I guess the index of the initial image is not set properly when the full screen is presented.

    Forget to mention I'm using the swift-3 branch :)

    bug 
    opened by ghost 6
  • After getting data from the Server and when i try to load if show blank white screen

    After getting data from the Server and when i try to load if show blank white screen

    Here is code i try to set it to new images which are downloaded self.homeSlideShow.setImageInputs(convertToAlmofireSource(sliderImages))

    //Code for getting data

    Alamofire.request(apiMethod("banners"), createUrl("banners", getPram: ["":""]), headers: headers)
                .responseSwiftyJSON({ (request, response, json, error) in
                    if error == nil {
                        let jsonData = json
                        if jsonData["error"].bool == false {
                            sliderImages.removeAll()
                            for item in jsonData["data"]{
                                sliderImages.append(createImgUrl("banners", imgName: item.1["img"].string!))
                            }
                            dataSource.setValue(sliderImages, forKey: "banners")
                            self.homeSlideShow.setImageInputs(convertToAlmofireSource(sliderImages))
    
                        }else if jsonData["error"].bool == true {
                            self.presentViewController(createAlert(jsonData["message"].string!), animated: true, completion: nil)
                        }
                    }else{
    
                        self.presentViewController(createAlert("internet"), animated: true, completion: nil)
    
                    }
                })
    

    //convert function

    func convertToAlmofireSource(images: [String]) -> [AlamofireSource]{
        let img = images
        var sliderImg = [AlamofireSource]()
        for item in img {
            sliderImg.append(AlamofireSource(urlString: item)!)
        }
    
        return sliderImg
    }
    

    Everthing works fine just it show white screen when i load new images

    bug 
    opened by O-mkar 6
  • slideshowInterval

    slideshowInterval

    Hi all I am using this library and i dont know way how to use these feature configure

    slideshowInterval - slideshow interval in seconds (default 0 – disabled) zoomEnabled - enables zooming (default false) circular - enables circular scrolling (default true) Can you help me?

    Thanks all

    opened by vickygaugau 0
  • Image blinks when scroll from the first one backward to the last one

    Image blinks when scroll from the first one backward to the last one

    When I scroll from the first image backward to the last one, sometime the slider will blink (please refer the video around 3-4 sec). I am using preload with fixed(offset: 1) to have that issue. If I switch to preload all images, that will not blink.

    P.S. Not sure if that related to the "loadImage()" and "releaseImage()" function. P.P.S. I am using KingfisherSource

    Thanks for the help.

    https://user-images.githubusercontent.com/49747552/180423680-54438ead-bbcc-4444-bdd1-72e5b14656d3.mov

    opened by christinachanhk 0
  • Recent version is targeted to iOS 10 and has issue when it used with the KingFisher integration

    Recent version is targeted to iOS 10 and has issue when it used with the KingFisher integration

    I'm using CI to build my App. So I can't change the target.

    /Users/[REDACTED]/git/Pods/ImageSlideshow/ImageSlideshow/Classes/InputSources/KingfisherSource.swift:13:8: compiling for iOS 10.0, but module 'Kingfisher' has a minimum deployment target of iOS 12.0: /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/KirOps-fyjarvswqgnloecwjincivxnewga/Build/Intermediates.noindex/ArchiveIntermediates/KirOps/BuildProductsPath/Release-iphoneos/Kingfisher/Kingfisher.framework/Modules/Kingfisher.swiftmodule/arm64-apple-ios.swiftmodule

    opened by villajohn 2
  • How to Stop Image Slide Show when moved to another ViewController

    How to Stop Image Slide Show when moved to another ViewController

    Even when I changed the transition from the page on which the image slide show is implemented, the SlideShow timer Still worked. how to stop imageSlideshow?

    opened by kumarsankk 0
Releases(1.9.1)
  • 1.6.1(Jun 11, 2018)

  • 1.6.0(May 27, 2018)

    New Features

    • Page Indicator customization (#251)

    Fixes

    • Fixed animation problem on orientation change (#234)
    • Fixed missing close button image in Carthage build (#247)
    Source code(tar.gz)
    Source code(zip)
  • 1.5.3(Apr 17, 2018)

  • 1.5.2(Apr 15, 2018)

    New Features

    • Example project demonstrating usage of Image Slideshow with parent UIImageView

    Fixes

    • Fix image shift on iPhone X landscape (#200)
    • Add closeButtonFrame property to Full Screen controller (#226)
    • Don't trigger interactive gesture recognizer on horizontal pans, fixes single image sliding issue (#224)
    • Fix interactive dismiss regression on iOS 11
    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Feb 4, 2018)

  • 1.5.0(Jan 21, 2018)

    New Features

    • Implement image load cancelling to optimize memory usage
    • Improve Kingfisher InputSource to take Options parameters
    • Update page control selected page during scrolling (#204)
    • Add possibility to change maximum zoom scale (#221)

    Fixes

    • SDWebImage dependency improvements (#205)
    • Fix possible division by zero crash (#187)
    • Adjust close button frame to respect SafeAreaInsets (#209)
    • Fix missing placeholder on AFURLSource (#218)
    • Fix incorrect currentPageChanged calls (#222)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(May 8, 2017)

    New Features

    • Possibility to show activity indicator during async loading
    • Hide UIPageControl when sllideshow has single item
    • UIScrollViewDelegate methods are now open instead of public

    Fixes

    • Fix zoom transition for when a slideshow has just a single item
    • Fix issue on zoomEnabled change
    Source code(tar.gz)
    Source code(zip)
    ImageSlideshow.framework.zip(2.11 MB)
  • 1.2.0(Mar 19, 2017)

    New Features

    • Improved placeholder handling on all remote input sources
    • Deprecated pauseTimerIfNeeded and unpauseTimerIfNeeded in favour of pauseTimer and unpauseTimer

    Fixes

    • Fix memory leak caused by incorrect timer invalidation
    • Partially fix an UI glitch happening when "in-call" status bar is on
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Feb 19, 2017)

    New Features

    • Add willBeginDragging and didEndDecelerating callback closures (@El-Fitz)
    • Add Parse input source (@jaimeagudo)

    Fixes

    • Fix image preload issue when scrolling between edges (#115)
    • Fix issue caused by disabling circular after setting input sources (#104)
    • Improve example project
    • Style fixes (@dogo)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Dec 11, 2016)

    Version 1.0 aims to improve stability and brings couple of new features. Also contains few backward complatibility breaking changes.

    New Features

    • New input source for Kingfisher (@feiin)
    • Add currentPageChanged closure to notify about page change (#54)
    • Add possibility to lazy load and release images (#42)
    • Easier way to present FullScreenSlideshowViewController (#72)
    • Documentation improvements

    Fixes

    • Fix the case when containing VC automatically adjusts scrollview insets (#71)
    • Fix crash during transition when no images set (#74)
    • Rounding error fix for page calculation (#90, @mjrehder)
    • Fix for black image when using fullscreen zoom (#92, @mjrehder)
    • Change page on UIPageControl page change (#80)
    • iOS 10 interactive transition interruption fix (5d5f22f)
    • Memory fixes

    API changes

    • currentItemIndex was renamed to currentPage
    • set function from InputSource protocol was renamed to load and have a new closure parameter called on image load
    Source code(tar.gz)
    Source code(zip)
    ImageSlideshow.framework.zip(1.71 MB)
  • 1.0.0-beta.1(Oct 29, 2016)

  • 0.6-swift3(Oct 29, 2016)

  • 0.6(Sep 21, 2016)

  • 0.5.1(Aug 20, 2016)

  • 0.5.0(Jun 9, 2016)

    The version 0.5 cleans up the code, adds interactive fullscreen dismiss and fixes few minor issues (thanks again, @kafejo) This version also contains several background compatibility breaks, so please keep this in mind when upgrading to it.

    New Features

    • Interactive dismiss transition on full screen controller
    • A possibility to open full screen controller from plain UIImageView

    API changes

    • ImageSlideshow: currentPage renamed to currentItemIndex
    • FullScreenSlideshowViewController: initialPage renamed to initialPageIndex
    • ZoomAnimatedTransitioning: added second parameter slideshowController: FullScreenSlideshowViewController to constructor
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Mar 29, 2016)

  • 0.3.1(Mar 18, 2016)

Owner
Petr Zvoníček
Software developer, currently into the iOS platform. Swift, ObjC, Python, JS.
Petr Zvoníček
A simple Image full screen pop up

CLImageViewPopup Description A simple UIImageView for easy fullscreen image pop up. No matter where your UIImageView may be. Image pops up from where

Vineeth Vijayan 36 Apr 29, 2021
A simple Image full screen pop up

CLImageViewPopup Description A simple UIImageView for easy fullscreen image pop up. No matter where your UIImageView may be. Image pops up from where

Vineeth Vijayan 36 Apr 29, 2021
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

Adnan Yousaf 11 Jan 10, 2022
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Nes 534 Jan 3, 2023
Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. We've added both user experience and technical features inspired by F

Thiago Peres 2.7k Dec 21, 2022
Lightbox is a convenient and easy to use image viewer for your iOS app

Lightbox is a convenient and easy to use image viewer for your iOS app, packed with all the features you expect: Paginated image slideshow. V

HyperRedink 1.5k Dec 22, 2022
A snappy image viewer with zoom and interactive dismissal transition.

A snappy image viewer with zoom and interactive dismissal transition. Features Double tap to zoom in/out Interactive dismissal transition Animate in f

Lucas 421 Dec 1, 2022
Slide image viewer library similar to Twitter and LINE.

Overview You can use it simply by passing the necessary information! Serrata is a UI library that allows you to intuitively view images. Features King

Takuma Horiuchi 324 Dec 9, 2022
A snappy image viewer with zoom and interactive dismissal transition.

A snappy image viewer with zoom and interactive dismissal transition. Features Double tap to zoom in/out Interactive dismissal transition Animate in f

Lucas 421 Dec 1, 2022
Agrume - 🍋 An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
Scrolling the image as a background in Swift

Scrolling the image as a background!

Aleksandr Bychkovskiy 0 Nov 7, 2021
How to create a circular and rectangular ImageView with similar image?

chapter11CircularAndRectangularImage How to create a circular and rectangular ImageView with similar image? I add two imageView in Main.storyboard I a

ahmetbostanciklioglu 0 Jan 8, 2022
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.

ATGMediaBrowser ATGMediaBrowser is an image slide-show viewer that supports multiple predefined transition styles, and also allows the client to defin

null 200 Dec 19, 2022
An image viewer à la Twitter

For the latest changes see the CHANGELOG Install CocoaPods pod 'ImageViewer' Carthage github "Krisiacik/ImageViewer" Sample Usage For a detailed examp

Kristian Angyal 2.4k Dec 29, 2022
A custom image view that implements device motion scrolling

YXTMotionView A custom image view that implements device motion scrolling Installation CocoaPods Add the dependency to your Podfile: platform :ios pod

Hanton Yang 79 Dec 17, 2022
A simple mesh viewer for MacOS based on Swift and Metal and using Assimp for loading meshes

Metal Mesh Viewer A simple triangle mesh viewer for MacOS This application is a simple (triangle) mesh viewer that should be capable of rendering even

J. Andreas Bærentzen 0 Dec 13, 2021
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) Simple PhotoBrowser

keishi suzuki 2.4k Jan 6, 2023
Swift/iOS viewer for photography galleries or portfolios

Swift/iOS viewer for photography galleries or portfolios. The app is intended for photographers who participate in classical photo clubs: a portfolio covers (curated) images that were presented and critiqued within a photo club.

Peter van den Hamer 8 Dec 24, 2022
A simple and flexible way to add source of overlapping circular pictures, currently supports horizontal overlapping or distant pictures with great layout flexibility.

THIS PROJECT IS NO LONGER MAINTAINED. STILL ONE ONLY BEST UI SOLUTION FOR UIKIT DEVELOPERS. SOON WILL COME UP WITH SWIFTUI STILL CONTRIBUTORS ARE WELC

Kiran Jasvanee 673 Dec 19, 2022