Git Product home page Git Product logo

imageslideshow's Introduction

πŸ–Ό ImageSlideshow

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.3'

Carthage

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

github "zvonicek/ImageSlideshow" "1.3"

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 builded 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 builded 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 and Swift 3 support

Version 1.0 supports Swift 3. 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/ParseSource"
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)
  • pageControlPosition - configures position of UIPageControl (default insideScrollView, also hidden, underScrollView or custom)
  • 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)

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:

imageslideshow's People

Contributors

bodagetta avatar colemancda avatar dogo avatar el-fitz avatar feiin avatar kumuluzz avatar mjrehder avatar nikkovios avatar omgbbqhaxx avatar zvonicek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.