Giter VIP home page Giter VIP logo

zcarousel's Introduction

ZCarousel

Swift Carousel using a Paged UIScrollView

This is a infite carousel made using a Paged UIScrollView and some easy maths. You can create a Carousel of UIImageViews or UIButtons.
Carousels must be of at least 3 items and as long as you want.


ZCarousel


**You need to add the ZCarousel Delegate to your Controller:**
class ViewController: UIViewController, ZCarouselDelegate {
}

**To create a UIButtons Carousel just go on and create a ZCarousel variable with frame. Set thee delegate and use the method .addButtons() and add it to your view.**
var menu = ZCarousel(frame: CGRect( x: self.view.frame.size.width/5,
            y: 100,
            width: (self.view.frame.size.width/5)*3,
            height: 50))
menu.ZCdelegate = self
menu.addButtons(["iOS 8 by Tutorials", "Swift by Tutorials", "Core Data by Tutorials", "WatchKit by Tutorials"])
        
self.view.addSubview(menu!)

**To create a UIImageViews Carousel just go on and create a ZCarousel variable with frame. Set thee delegate and use the method .addImages() and add it to your view.**
Note: Just add the image title as a String.
images = ZCarousel(frame: CGRect( x: self.view.frame.size.width/5,
            y: 200,
            width: (self.view.frame.size.width/5)*3,
            height: 150))
images.ZCdelegate = self
images.addImages(["1", "2", "3"])

self.view.addSubview(images)

**Add the delegate function ZCarouselShowingIndex() to your controller to know the index showing.**
Note: scrollview is to know the difference between two ZCarousels and show the correct index if both are on the same controller ```swift func ZCarouselShowingIndex(scrollview: ZCarousel, index: Int) { if scrollview == menu { println("Showing Button at index \(index)") } else if scrollview == images { println("Showing Image at index \(index)") } } ```

Hope you find it useful.

Follow me on Twitter @richzertuche

[![Join the chat at https://gitter.im/richzertuche/ZCarousel](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/richzertuche/ZCarousel?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

zcarousel's People

Contributors

richzertuche avatar jacks205 avatar ahmedb avatar gitter-badger 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.