Giter Site home page Giter Site logo

ankitthakur / etcarouswift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from helenhell/etcarouswift

0.0 1.0 0.0 11.92 MB

A user-friendly and developer-friendly carousel framework

License: MIT License

Swift 65.13% Objective-C 31.53% Ruby 3.34%

etcarouswift's Introduction

ETCarouSwift

A user-friendly and developer-friendly carousel framework. ETCarouSwift receives a bunch of images and creates a smooth infinite ride inside the given frame. Dragging is also avaliable along with other handy settings. Simple, light and flawless.

Demo

Click on the screnshot to try an interactive demo by appetize.io

Requirements

  • iOS 13.0+
  • XCode 11.3

Installation

CocoaPods

You can use CocoaPods to install ETCarouSwift by adding it to your Podfile:

# Pods for YourProject

   pod 'ETCarouSwift'

Manually

  1. Download ETCarouSwiftDemo
  2. Drag ETCarouSwift.framework to the root of Your Project
  3. Don't forget to check copy items if needed
  4. Enjoy

Or

  1. Download ETCarouSwift repo
  2. Copy ETCarouSwift folder into YourProject
  3. That's it

Usage

Get started

To get the full benefits import ETCarouSwift wherever you import UIKit

import UIKit
import ETCarouSwift 

Initialize CarouView with desired frame and bunch of images. Set rideDirection as well if needed. Default is .rightToLeft:

let images:[UIImage] = [UIImage(named: "1")!,
                        UIImage(named: "2")!,
                        UIImage(named: "3")!,
                        UIImage(named: "4")!,
                        UIImage(named: "5")!]
                        
 let frame = CGRect(x: 10, y: 100, width: 300, height: 200)
 
 let carouView = CarouView(frame: frame, imageSet: images, rideDirection: .leftToRight)

Add CarouView to the main view:

self.view.addSubview(carouView)

Settings

  1. AutoRide is enabled by default. If you want to cancel it:
carouView.autoRideEnabled = false
  1. Page indicator dot color & current dot color:
carouView.dotColor = UIColor.white
carouView.currentDotColor = UIColor.black
  1. Dot size. Default is .small
carouView.dotSize = .medium
  1. Show time. Default is 2 seconds. Relevant when autoRide is enabled.
carouView.showTime = 3.5

Delegate

Make your controller an inheritor of CarouViewDelegate protocol:

class ViewController:UIViewController, CarouViewDelegate {

Initialize you carouView delegate with your controller property:

carouView.delegate = self

Use two delegate methods:

func carouViewDidChangeImage(_ carouView: CarouView, index currentImageIndex: Int) {
        
    //Do something when image changed
        
}
func carouView(_ carouView: CarouView, didTapImageAt index: Int) {
    
    //Do something on image tap
}

Author

Elena Slovushch

License

This project is licensed under the MIT License - see the LICENSE.md file for details

etcarouswift's People

Contributors

helenhell avatar ankitthakur avatar

Watchers

James Cloos 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.