Git Product home page Git Product logo

kaslideshow's Introduction

#KASlideShow

Slideshow for iOS. Easy to use. Support manual or automatic slideshow, with fade and slide transitions. Support local and remote images.

Demo screenshot

##version 3.0.0 changelog

This version introduces a lot of breaking changes. Make sure to have a look at the demo.

  • Usage is now centered around the datasource protocol.
  • Changed datasource and delegate protocols methods for more consistency
  • Introducing the long awaited remote image handling! Just put a valid image NSURL into your datasource and you're all set.

##Install

###Normal install

Simply copy into your project folder :

  • KASlideShow.h
  • KASlideShow.m

###Using cocoapods

add this line to your Podfile : pod 'KASlideShow'

##Usage

###Quick example

- (void)viewDidLoad
{
    [super viewDidLoad];
    _datasource = @[[UIImage imageNamed:@"test_1.jpg"],
                    [NSURL URLWithString:@"https://i.imgur.com/7jDvjyt.jpg"],
                    @"test_3.jpg"];

    _slideshow = [[KASlideShow alloc] initWithFrame:CGRectMake(0,0,320,250)];
    _slideshow.datasource = self;
    _slideshow.delegate = self;
    [_slideshow setDelay:3]; // Delay between transitions
    [_slideshow setTransitionDuration:1]; // Transition duration
    [_slideshow setTransitionType:KASlideShowTransitionFade]; // Choose a transition type 
    [_slideshow setImagesContentMode:UIViewContentModeScaleAspectFill]; // Choose a content mode for images to display
    [_slideshow addGesture:KASlideShowGestureTap]; // Gesture to go previous/next directly on the image
}

#pragma mark - KASlideShow datasource

- (NSObject *)slideShow:(KASlideShow *)slideShow objectAtIndex:(NSUInteger)index
{
    return _datasource[index];
}

- (NSUInteger)slideShowImagesNumber:(KASlideShow *)slideShow
{
    return _datasource.count;
}

#pragma mark - KASlideShow delegate

- (void) slideShowWillShowNext:(KASlideShow *)slideShow
{
    NSLog(@"slideShowWillShowNext, index : %@",@(slideShow.currentIndex));
}

###KASlideShowDataSource

You need to implement the datasource to display images. KASlideShow can handle UIImage, NNString (name of local image) and NSURL (URL of remote image).

- (NSObject *) slideShow:(KASlideShow *)slideShow objectAtIndex:(NSUInteger)index;
- (NSUInteger) slideShowImagesNumber:(KASlideShow *)slideShow;

###Use of a slideshow

[_slideshow next]; // Go to the next image
[_slideshow previous]; // Got to the previous image
[_slideshow start]; // Start automatic slideshow
[_slideshow stop]; // Stop automatic slideshow

###KASlideShowDelegate

- (void) slideShowDidShowNext:(KASlideShow *) slideShow;
- (void) slideShowDidShowPrevious:(KASlideShow *) slideShow;
- (void) slideShowWillShowNext:(KASlideShow *) slideShow;
- (void) slideShowWillShowPrevious:(KASlideShow *) slideShow;
- (void) slideShowDidSwipeLeft:(KASlideShow *) slideShow;
- (void) slideShowDidSwipeRight:(KASlideShow *) slideShow;

###Transitions

Here are the 3 available types of transitions you can set via setTransitionType.

    KASlideShowTransitionFade
    KASlideShowTransitionSlideHorizontal
    KASlideShowTransitionSlideVertical

You can furthermore specify the transition duration via setTransitionDuration.

###Gestures

Two types gestures are available to interact with the slideshow via the addGesture method. It is possible to add them both.

    KASlideShowTransitionFade
    KASlideShowTransitionSlideHorizontal
    KASlideShowTransitionSlideVertical

kaslideshow's People

Contributors

alexiscreuzot avatar jerrygdm avatar sadiq81 avatar brandonscript avatar realbug avatar kliffy avatar egold avatar babac87 avatar allfake avatar

Watchers

James Cloos avatar Prigozhenkov Maxim 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.